annotate src/evalfunc.c @ 18094:a1396a35444c v8.1.2042

patch 8.1.2042: the evalfunc.c file is too big Commit: https://github.com/vim/vim/commit/9c658c9eacbd97e2c071f652a0155f71db94c0f3 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 15 21:00:54 2019 +0200 patch 8.1.2042: the evalfunc.c file is too big Problem: The evalfunc.c file is too big. Solution: Move getchar() and parse_queued_messages() to getchar.c.
author Bram Moolenaar <Bram@vim.org>
date Sun, 15 Sep 2019 21:15:03 +0200
parents 9d6832a5426f
children e59ff7b5d7a7
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
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12564
diff changeset
23 #ifdef 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_cindent(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_col(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_confirm(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 static void f_copy(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 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
60 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
61 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 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
63 #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
64 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
65 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 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
77 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 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
79 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
80 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
81 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 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
83 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
84 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
85 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 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
110 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
111 static void f_indent(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_index(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_input(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_inputdialog(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_inputlist(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_inputrestore(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 static void f_inputsave(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 static void 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
119 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
120 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
121 #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
122 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
123 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
124 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 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
126 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
127 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
128 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
129 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
130 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
131 static void f_lispindent(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 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
133 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 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
135 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
136 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 #ifdef FEAT_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 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
139 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 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
141 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
142 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
143 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
144 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
145 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
146 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
147 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
148 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
149 static void f_mode(typval_T *argvars, typval_T *rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 #ifdef FEAT_MZSCHEME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 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
152 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 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
154 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
155 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
156 #ifdef FEAT_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 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
158 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 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
161 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 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
163 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
164 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
165 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
166 #ifdef FEAT_PYTHON3
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 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
168 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 #ifdef FEAT_PYTHON
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 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
171 #endif
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
172 #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
173 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
174 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 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
176 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
177 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
178 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
179 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 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
181 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 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
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192 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
193 #endif
16103
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
194 #ifdef FEAT_RUBY
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
195 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
196 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 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
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 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
206 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
207 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
208 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
209 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
210 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
211 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
212 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
213 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
214 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
215 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
216 #ifdef FEAT_CRYPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 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
218 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219 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
220 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
221 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 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
223 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
224 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 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
226 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
227 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
228 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
229 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 static void 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
231 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
232 #endif
16235
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
233 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
234 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
235 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
236 #ifdef HAVE_STRFTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 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
238 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 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
240 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
241 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
242 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
243 static void 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
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 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
262 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
263 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 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
265 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
266 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
267 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
268 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
269 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
270 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271 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
272 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
273 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
274 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
275 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
276 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
277
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
278 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
279 * 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
280 * 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
281 */
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
282 typedef struct
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283 {
17620
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
284 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
285 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
286 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
287 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
288 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
289 // implementation of function
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
290 } funcentry_T;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
291
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
292 // 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
293 #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
294 #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
295 #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
296 #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
297 #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
298
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
299 static funcentry_T global_functions[] =
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 #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
302 {"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
303 {"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
304 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
305 {"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
306 {"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
307 {"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
308 {"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
309 {"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
310 {"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
311 {"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
312 {"argv", 0, 2, 0, f_argv},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 #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
314 {"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
315 #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
316 {"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
317 {"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
318 {"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
319 {"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
320 {"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
321 {"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
322 {"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
323 {"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
324 {"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
325 {"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
326 {"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
327 {"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
328 #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
329 {"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
330 {"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
331 #endif
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
332 #ifdef FEAT_BEVAL
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
333 {"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
334 {"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
335 # 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
336 {"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
337 # endif
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
338 #endif
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
339 {"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
340 {"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
341 {"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
342 {"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
343 {"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
344 {"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
345 {"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
346 {"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
347 {"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
348 {"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
349 {"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
350 {"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
351 {"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
352 {"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
353 {"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
354 {"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
355 {"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
356 {"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
357 #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
358 {"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
359 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 #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
361 {"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
362 {"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
363 {"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
364 {"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
365 {"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
366 {"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
367 {"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
368 {"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
369 {"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
370 {"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
371 {"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
372 {"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
373 {"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
374 {"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
375 {"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
376 {"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
377 {"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
378 {"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
379 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
380 {"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
381 {"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
382 {"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
383 {"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
384 {"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
385 {"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
386 {"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
387 {"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
388 {"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
389 {"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
390 {"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
391 {"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
392 #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
393 {"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
394 {"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
395 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
396 {"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
397 {"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
398 {"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
399 #ifdef MSWIN
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
400 {"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
401 #endif
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17831
diff changeset
402 {"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
403 {"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
404 {"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
405 {"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
406 {"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
407 {"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
408 {"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
409 {"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
410 {"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
411 {"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
412 {"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
413 {"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
414 {"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
415 {"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
416 {"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
417 #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
418 {"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
419 #endif
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
420 {"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
421 {"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
422 {"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
423 {"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
424 {"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
425 {"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
426 {"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
427 {"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
428 {"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
429 {"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
430 #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
431 {"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
432 {"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
433 {"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
434 #endif
17849
73ddc462979d patch 8.1.1921: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
435 {"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
436 {"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
437 {"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
438 {"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
439 {"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
440 {"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
441 {"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
442 {"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
443 {"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
444 {"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
445 {"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
446 {"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
447 {"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
448 {"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
449 {"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
450 {"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
451 {"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
452 {"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
453 {"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
454 {"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
455 {"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
456 {"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
457 {"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
458 {"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
459 {"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
460 {"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
461 {"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
462 {"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
463 {"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
464 {"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
465 {"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
466 {"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
467 {"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
468 {"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
469 {"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
470 {"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
471 {"getmatches", 0, 1, 0, f_getmatches},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
472 {"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
473 {"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
474 {"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
475 {"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
476 {"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
477 {"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
478 {"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
479 {"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
480 {"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
481 {"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
482 {"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
483 {"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
484 {"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
485 {"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
486 {"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
487 {"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
488 {"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
489 {"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
490 {"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
491 {"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
492 {"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
493 {"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
494 {"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
495 {"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
496 {"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
497 {"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
498 {"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
499 {"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
500 {"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
501 {"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
502 {"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
503 {"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
504 {"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
505 {"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
506 {"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
507 {"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
508 {"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
509 {"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
510 {"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
511 {"insert", 2, 3, FEARG_1, f_insert},
17783
45eca7143d7c patch 8.1.1888: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
512 {"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
513 {"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
514 #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
515 {"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
516 #endif
17914
af3d441845cd patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17912
diff changeset
517 {"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
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 {"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
520 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
521 {"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
522 #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
523 {"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
524 {"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
525 {"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
526 {"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
527 {"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
528 {"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
529 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
530 {"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
531 {"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
532 {"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
533 {"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
534 {"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
535 {"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
536 {"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
537 {"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
538 {"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
539 {"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
540 {"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
541 {"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
542 {"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
543 {"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
544 {"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
545 {"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
546 {"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
547 {"localtime", 0, 0, 0, f_localtime},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
548 #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
549 {"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
550 {"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
551 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
552 #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
553 {"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
554 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
555 {"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
556 {"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
557 {"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
558 {"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
559 {"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
560 {"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
561 {"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
562 {"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
563 {"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
564 {"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
565 {"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
566 {"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
567 {"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
568 {"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
569 {"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
570 {"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
571 #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
572 {"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
573 #endif
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
574 {"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
575 {"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
576 {"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
577 {"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
578 #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
579 {"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
580 #endif
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
581 #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
582 {"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
583 {"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
584 {"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
585 {"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
586 {"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
587 {"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
588 {"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
589 {"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
590 {"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
591 {"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
592 {"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
593 {"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
594 {"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
595 {"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
596 {"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
597 {"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
598 {"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
599 {"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
600 {"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
601 {"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
602 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
603 #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
604 {"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
605 #endif
17976
6d11a0d5751d patch 8.1.1984: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17972
diff changeset
606 {"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
607 {"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
608 #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
609 {"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
610 {"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
611 {"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
612 #endif
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
613 #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
614 {"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
615 {"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
616 {"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
617 {"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
618 {"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
619 {"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
620 {"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
621 {"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
622 {"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
623 #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
624 {"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
625 {"pumvisible", 0, 0, 0, f_pumvisible},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
626 #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
627 {"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
628 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
629 #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
630 {"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
631 #endif
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
632 #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
633 {"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
634 #endif
17982
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
635 {"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
636 {"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
637 {"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
638 {"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
639 {"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
640 {"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
641 #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
642 {"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
643 #endif
2029737e6a22 patch 8.1.1987: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17980
diff changeset
644 {"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
645 {"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
646 {"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
647 {"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
648 {"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
649 {"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
650 {"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
651 {"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
652 {"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
653 {"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
654 {"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
655 {"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
656 #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
657 {"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
658 #endif
16103
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
659 #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
660 {"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
661 #endif
17994
0dcc2ee838dd patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17986
diff changeset
662 {"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
663 {"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
664 {"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
665 {"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
666 {"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
667 {"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
668 {"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
669 {"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
670 {"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
671 {"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
672 {"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
673 {"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
674 {"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
675 {"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
676 {"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
677 {"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
678 {"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
679 {"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
680 {"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
681 {"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
682 {"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
683 {"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
684 {"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
685 {"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
686 {"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
687 {"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
688 {"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
689 {"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
690 {"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
691 {"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
692 #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
693 {"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
694 #endif
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
695 {"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
696 {"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
697 #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
698 {"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
699 {"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
700 {"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
701 {"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
702 {"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
703 {"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
704 {"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
705 {"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
706 {"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
707 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
708 {"simplify", 1, 1, 0, f_simplify},
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
709 #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
710 {"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
711 {"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
712 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
713 {"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
714 #ifdef FEAT_SOUND
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
715 {"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
716 {"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
717 {"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
718 {"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
719 #endif
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
720 {"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
721 {"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
722 {"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
723 {"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
724 #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
725 {"sqrt", 1, 1, FEARG_1, f_sqrt},
545119cd5554 patch 8.1.1879: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17756
diff changeset
726 {"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
727 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
728 {"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
729 {"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
730 {"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
731 {"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
732 {"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
733 #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
734 {"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
735 #endif
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
736 {"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
737 {"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
738 {"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
739 {"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
740 {"strpart", 2, 3, FEARG_1, f_strpart},
988e5a868b60 patch 8.1.2004: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
741 {"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
742 {"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
743 {"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
744 {"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
745 {"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
746 {"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
747 {"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
748 {"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
749 {"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
750 {"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
751 {"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
752 {"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
753 {"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
754 {"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
755 {"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
756 {"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
757 {"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
758 {"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
759 {"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
760 #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
761 {"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
762 {"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
763 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
764 {"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
765 #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
766 {"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
767 {"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
768 {"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
769 {"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
770 # 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
771 {"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
772 # endif
18033
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
773 {"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
774 {"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
775 {"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
776 {"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
777 {"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
778 {"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
779 {"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
780 {"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
781 {"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
782 {"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
783 {"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
784 {"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
785 # 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
786 {"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
787 # endif
18033
049a7481d737 patch 8.1.2012: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18031
diff changeset
788 {"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
789 {"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
790 {"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
791 {"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
792 {"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
793 #endif
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
794 {"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
795 {"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
796 {"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
797 {"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
798 {"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
799 {"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
800 {"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
801 {"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
802 #ifdef FEAT_JOB_CHANNEL
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
803 {"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
804 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
805 {"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
806 #ifdef FEAT_JOB_CHANNEL
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
807 {"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
808 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
809 {"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
810 {"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
811 {"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
812 {"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
813 {"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
814 {"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
815 #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
816 {"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
817 #endif
16568
9e991ede1b59 patch 8.1.1287: cannot build with +eval but without +mouse
Bram Moolenaar <Bram@vim.org>
parents: 16527
diff changeset
818 #ifdef FEAT_MOUSE
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
819 {"test_setmouse", 2, 2, 0, f_test_setmouse},
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
820 #endif
18031
8a2fb21c23c0 patch 8.1.2011: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18017
diff changeset
821 {"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
822 #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
823 {"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
824 {"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
825 {"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
826 {"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
827 {"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
828 #endif
18035
11dca9732a48 patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 18033
diff changeset
829 {"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
830 {"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
831 {"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
832 {"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
833 #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
834 {"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
835 #endif
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
836 {"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
837 {"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
838 {"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
839 {"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
840 {"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
841 {"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
842 {"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
843 {"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
844 {"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
845 {"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
846 {"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
847 {"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
848 {"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
849 {"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
850 {"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
851 {"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
852 {"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
853 {"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
854 {"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
855 {"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
856 {"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
857 {"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
858 {"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
859 {"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
860 {"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
861 {"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
862 {"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
863 {"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
864 {"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
865 };
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
866
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
867 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
868 * 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
869 * or user defined function names.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
870 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
871 char_u *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
872 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
873 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
874 static int intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
875 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
876
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
877 if (idx == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
878 intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
879 if (intidx < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
880 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
881 name = get_user_func_name(xp, idx);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
882 if (name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
883 return name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
884 }
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
885 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
886 {
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
887 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
888 STRCAT(IObuff, "(");
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
889 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
890 STRCAT(IObuff, ")");
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
891 return IObuff;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
892 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
893
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
894 return NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
895 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
896
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
897 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
898 * 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
899 * user defined variable or function names.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
900 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
901 char_u *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
902 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
903 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
904 static int intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
905 char_u *name;
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 if (idx == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
908 intidx = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
909 if (intidx < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
910 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
911 name = get_function_name(xp, idx);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
912 if (name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
913 return name;
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 return get_user_var_name(xp, ++intidx);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
916 }
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 /*
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
919 * 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
920 * Return index, or -1 if not found
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
921 */
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
922 static int
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
923 find_internal_func(char_u *name)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
924 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
925 int first = 0;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
926 int last;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
927 int cmp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
928 int x;
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 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
931
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
932 // 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
933 while (first <= last)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
934 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
935 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
936 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
937 if (cmp < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
938 last = x - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
939 else if (cmp > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
940 first = x + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
941 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
942 return x;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
943 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
944 return -1;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
947 int
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
948 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
949 {
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
950 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
951 }
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
952
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
953 int
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
954 call_internal_func(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
955 char_u *name,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
956 int argcount,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
957 typval_T *argvars,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
958 typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
959 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
960 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
961
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
962 i = find_internal_func(name);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
963 if (i < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
964 return ERROR_UNKNOWN;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
965 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
966 return ERROR_TOOFEW;
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
967 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
968 return ERROR_TOOMANY;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
969 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
970 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
971 return ERROR_NONE;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
972 }
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
973
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
974 /*
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
975 * 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
976 */
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
977 int
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
978 call_internal_method(
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
979 char_u *name,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
980 int argcount,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
981 typval_T *argvars,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
982 typval_T *rettv,
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
983 typval_T *basetv)
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 int i;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
986 int fi;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
987 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
988
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
989 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
990 if (fi < 0)
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
991 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
992 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
993 return ERROR_NOTMETHOD;
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
994 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
995 return ERROR_TOOFEW;
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
996 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
997 return ERROR_TOOMANY;
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
998
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
999 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
1000 {
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1001 // 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
1002 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
1003 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
1004 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
1005 }
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1006 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
1007 {
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1008 // 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
1009 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
1010 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
1011 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
1012 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
1013 }
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
1014 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
1015 {
68ea27d26d5b patch 8.1.1861: only some assert functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17704
diff changeset
1016 // 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
1017 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
1018 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
1019 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
1020 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
1021 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
1022 }
18000
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
1023 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
1024 {
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
1025 // 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
1026 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
1027 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
1028 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
1029 argv[3] = *basetv;
7a19c8d6bb9e patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17998
diff changeset
1030 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
1031 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
1032 }
17620
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1033 else
072efa9ca875 patch 8.1.1807: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents: 17612
diff changeset
1034 {
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1035 // 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
1036 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
1037 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
1038 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
1039 }
17612
e259d11e2900 patch 8.1.1803: all builtin functions are global
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
1040 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
1041
17636
1687c8935ab6 patch 8.1.1815: duplicating info for internal functions
Bram Moolenaar <Bram@vim.org>
parents: 17624
diff changeset
1042 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
1043 return ERROR_NONE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1044 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1045
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1046 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1047 * 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
1048 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1049 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1050 non_zero_arg(typval_T *argvars)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1051 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1052 return ((argvars[0].v_type == VAR_NUMBER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1053 && argvars[0].vval.v_number != 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1054 || (argvars[0].v_type == VAR_SPECIAL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1055 && argvars[0].vval.v_number == VVAL_TRUE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1056 || (argvars[0].v_type == VAR_STRING
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1057 && argvars[0].vval.v_string != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1058 && *argvars[0].vval.v_string != NUL));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1059 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1060
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1061 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1062 * Get the lnum from the first argument.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1063 * 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
1064 * Returns -1 on error.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1065 */
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17178
diff changeset
1066 linenr_T
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1067 tv_get_lnum(typval_T *argvars)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1068 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1069 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1070
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1071 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
1072 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
1073 {
1f6d5f9ddeb0 patch 8.1.1974: Coverity warns for using pointer as array
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
1074 int fnum;
1f6d5f9ddeb0 patch 8.1.1974: Coverity warns for using pointer as array
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
1075 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
1076
1f6d5f9ddeb0 patch 8.1.1974: Coverity warns for using pointer as array
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
1077 if (fp != NULL)
1f6d5f9ddeb0 patch 8.1.1974: Coverity warns for using pointer as array
Bram Moolenaar <Bram@vim.org>
parents: 17942
diff changeset
1078 lnum = fp->lnum;
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 return lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1081 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1082
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1083 /*
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1084 * 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
1085 * 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
1086 * 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
1087 */
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
1088 linenr_T
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1089 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
1090 {
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1091 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
1092 && 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
1093 && 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
1094 && buf != NULL)
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1095 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
1096 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
1097 }
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1098
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1099 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1100 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1101 * 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
1102 * 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
1103 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1104 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1105 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
1106 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1107 if (argvars[0].v_type == VAR_FLOAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1108 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1109 *f = argvars[0].vval.v_float;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1110 return OK;
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 if (argvars[0].v_type == VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1113 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1114 *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
1115 return OK;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1116 }
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1117 emsg(_("E808: Number or Float required"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1118 return FAIL;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1121 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1122 * "abs(expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1123 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1124 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1125 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
1126 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1127 if (argvars[0].v_type == VAR_FLOAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1128 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1129 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1130 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
1131 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1132 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1133 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1134 varnumber_T n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1135 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1136
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1137 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
1138 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1139 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1140 else if (n > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1141 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1142 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1143 rettv->vval.v_number = -n;
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 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1146
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1147 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1148 * "acos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1149 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1150 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1151 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
1152 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1153 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1154
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1155 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1156 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1157 rettv->vval.v_float = acos(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1158 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1159 rettv->vval.v_float = 0.0;
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1162
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 * "and(expr, expr)" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1167 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
1168 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1169 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
1170 & 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
1171 }
acb2dc112b06 patch 8.1.0037: cannot easily append lines to another buffer
Christian Brabandt <cb@256bit.org>
parents: 14019
diff changeset
1172
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1173 #ifdef FEAT_FLOAT
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 * "asin()" 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_asin(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1179 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1180 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1181
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1182 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1183 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1184 rettv->vval.v_float = asin(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1185 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1186 rettv->vval.v_float = 0.0;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1189 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1190 * "atan()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1191 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1192 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1193 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
1194 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1195 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1196
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1197 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1198 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1199 rettv->vval.v_float = atan(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1200 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1201 rettv->vval.v_float = 0.0;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1204 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1205 * "atan2()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1206 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1207 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1208 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
1209 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1210 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
1211
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1212 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1213 if (get_float_arg(argvars, &fx) == OK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1214 && get_float_arg(&argvars[1], &fy) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1215 rettv->vval.v_float = atan2(fx, fy);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1216 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1217 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1218 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1219 #endif
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 /*
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1222 * "balloon_show()" function
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1223 */
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1224 #ifdef FEAT_BEVAL
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1225 static void
16600
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1226 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
1227 {
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1228 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
1229 if (balloonEval != NULL)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1230 {
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1231 if (balloonEval->msg == NULL)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1232 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
1233 else
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1234 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
1235 }
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1236 }
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1237
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1238 static void
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1239 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
1240 {
11020
50f3e37bc210 patch 8.0.0399: crash when using balloon_show() when not supported
Christian Brabandt <cb@256bit.org>
parents: 11014
diff changeset
1241 if (balloonEval != NULL)
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1242 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1243 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
1244 # ifdef FEAT_GUI
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1245 && !gui.in_use
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1246 # endif
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1247 )
16600
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 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
1250
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1251 // 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
1252 post_balloon(balloonEval, NULL,
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1253 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
1254 }
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1255 else
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1256 {
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1257 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
1258
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1259 if (mesg != NULL)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
1260 // 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
1261 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
1262 }
12883
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1263 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1264 }
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1265
12885
10cb5c3df3f5 patch 8.0.1319: can't build GUI on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
1266 # 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
1267 static void
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1268 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
1269 {
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1270 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
1271 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1272 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
1273
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1274 if (msg != NULL)
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 pumitem_T *array;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1277 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
1278 int i;
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1279
058e93aee621 patch 8.0.1318: terminal balloon only shows one line
Christian Brabandt <cb@256bit.org>
parents: 12871
diff changeset
1280 /* 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
1281 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
1282 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
1283 while (size > 0)
fee03d646e42 patch 8.0.1492: memory leak in balloon_split()
Christian Brabandt <cb@256bit.org>
parents: 13229
diff changeset
1284 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
1285 vim_free(array);
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 }
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1288 }
12885
10cb5c3df3f5 patch 8.0.1319: can't build GUI on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12883
diff changeset
1289 # endif
11014
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1290 #endif
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1291
fb2bcfa6a8de patch 8.0.0396: 'balloonexpr' only works synchronously
Christian Brabandt <cb@256bit.org>
parents: 11006
diff changeset
1292 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1293 * Get buffer by number or pattern.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1294 */
11846
1c65cad8b967 patch 8.0.0804: terminal window functions not yet implemented
Christian Brabandt <cb@256bit.org>
parents: 11828
diff changeset
1295 buf_T *
15355
73b153ed5af8 patch 8.1.0685: get_buf_tv() is named inconsistently
Bram Moolenaar <Bram@vim.org>
parents: 15343
diff changeset
1296 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
1297 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1298 char_u *name = tv->vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1299 buf_T *buf;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1300
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1301 if (tv->v_type == VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1302 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
1303 if (tv->v_type != VAR_STRING)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1304 return NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1305 if (name == NULL || *name == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1306 return curbuf;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1307 if (name[0] == '$' && name[1] == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1308 return lastbuf;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1309
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1310 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
1311
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1312 /* 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
1313 if (buf == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1314 buf = find_buffer(tv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1315
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1316 return buf;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1317 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1318
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1319 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1320 * 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
1321 * valid.
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1322 */
16638
4790302965fc patch 8.1.1321: no docs or tests for listener functions
Bram Moolenaar <Bram@vim.org>
parents: 16634
diff changeset
1323 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
1324 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
1325 {
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1326 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
1327
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1328 ++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
1329 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
1330 --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
1331 if (buf == NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1332 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
1333 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
1334 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1335
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1336 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1337 * "byte2line(byte)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1338 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1339 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1340 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
1341 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1342 #ifndef FEAT_BYTEOFF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1343 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1344 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1345 long boff = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1346
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1347 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
1348 if (boff < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1349 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1350 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1351 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
1352 (linenr_T)0, &boff);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1353 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1354 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1355
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1356 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1357 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
1358 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1359 char_u *t;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1360 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1361 varnumber_T idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1362
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1363 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
1364 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
1365 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1366 if (str == NULL || idx < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1367 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1368
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1369 t = str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1370 for ( ; idx > 0; idx--)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1371 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1372 if (*t == NUL) /* EOL reached */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1373 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1374 if (enc_utf8 && comp)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1375 t += utf_ptr2len(t);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1376 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1377 t += (*mb_ptr2len)(t);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1378 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1379 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
1380 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1381
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 * "byteidx()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1384 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1385 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1386 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
1387 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1388 byteidx(argvars, rettv, FALSE);
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
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 * "byteidxcomp()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1395 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
1396 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1397 byteidx(argvars, rettv, TRUE);
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
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 * "call(func, arglist [, dict])" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1404 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
1405 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1406 char_u *func;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1407 partial_T *partial = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1408 dict_T *selfdict = NULL;
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 if (argvars[1].v_type != VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1411 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1412 emsg(_(e_listreq));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1413 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1414 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1415 if (argvars[1].vval.v_list == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1416 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1417
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1418 if (argvars[0].v_type == VAR_FUNC)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1419 func = argvars[0].vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1420 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
1421 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1422 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
1423 func = partial_name(partial);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1424 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1425 else
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1426 func = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1427 if (*func == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1428 return; /* type error or empty name */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1429
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1430 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1431 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1432 if (argvars[2].v_type != VAR_DICT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1433 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1434 emsg(_(e_dictreq));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1435 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1436 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1437 selfdict = argvars[2].vval.v_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1438 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1439
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1440 (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
1441 }
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 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1444 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1445 * "ceil({float})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1446 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1447 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1448 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
1449 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1450 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1451
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1452 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1453 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1454 rettv->vval.v_float = ceil(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1455 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1456 rettv->vval.v_float = 0.0;
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1459
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 * "changenr()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1464 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
1465 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1466 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
1467 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1470 * "char2nr(string)" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1473 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
1474 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1475 if (has_mbyte)
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 int utf8 = 0;
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 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
1480 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
1481
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1482 if (utf8)
15967
ddd82b1c9e9d patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents: 15955
diff changeset
1483 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
1484 else
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1485 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
1486 }
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1487 else
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
1488 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
1489 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1490
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1491 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1492 * "cindent(lnum)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1493 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1494 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1495 f_cindent(typval_T *argvars UNUSED, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1496 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1497 #ifdef FEAT_CINDENT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1498 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1499 linenr_T lnum;
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 pos = curwin->w_cursor;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1502 lnum = tv_get_lnum(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1503 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
1504 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1505 curwin->w_cursor.lnum = lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1506 rettv->vval.v_number = get_c_indent();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1507 curwin->w_cursor = pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1508 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1509 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1510 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1511 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1512 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1513
17472
dfd87ef822aa patch 8.1.1734: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17377
diff changeset
1514 win_T *
16158
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1515 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
1516 {
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1517 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
1518
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1519 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
1520 {
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1521 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
1522 if (win == NULL)
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1523 {
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1524 emsg(_(e_invalwindow));
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1525 return NULL;
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1526 }
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1527 }
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1528 return win;
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1529 }
aef0f93d3eba patch 8.1.1084: cannot delete a match from another window
Bram Moolenaar <Bram@vim.org>
parents: 16144
diff changeset
1530
9571
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 * "col(string)" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1535 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
1536 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1537 colnr_T col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1538 pos_T *fp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1539 int fnum = curbuf->b_fnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1540
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1541 fp = var2fpos(&argvars[0], FALSE, &fnum);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1542 if (fp != NULL && fnum == curbuf->b_fnum)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1543 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1544 if (fp->col == MAXCOL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1545 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1546 /* '> 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
1547 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
1548 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
1549 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1550 col = MAXCOL;
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 else
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 col = fp->col + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1555 /* 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
1556 * 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
1557 if (virtual_active() && fp == &curwin->w_cursor)
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 char_u *p = ml_get_cursor();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1560
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1561 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
1562 curwin->w_virtcol - curwin->w_cursor.coladd))
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 int l;
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 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
1567 col += l;
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 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1570 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1571 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1572 rettv->vval.v_number = col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1573 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1574
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1575 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1576 * "confirm(message, buttons[, default [, type]])" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1577 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1578 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1579 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
1580 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1581 #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
1582 char_u *message;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1583 char_u *buttons = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1584 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1585 char_u buf2[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1586 int def = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1587 int type = VIM_GENERIC;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1588 char_u *typestr;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1589 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1590
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1591 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
1592 if (message == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1593 error = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1594 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1595 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1596 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
1597 if (buttons == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1598 error = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1599 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1600 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1601 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
1602 if (argvars[3].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1603 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1604 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
1605 if (typestr == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1606 error = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1607 else
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 switch (TOUPPER_ASC(*typestr))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1610 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1611 case 'E': type = VIM_ERROR; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1612 case 'Q': type = VIM_QUESTION; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1613 case 'I': type = VIM_INFO; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1614 case 'W': type = VIM_WARNING; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1615 case 'G': type = VIM_GENERIC; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1616 }
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 }
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 if (buttons == NULL || *buttons == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1623 buttons = (char_u *)_("&Ok");
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 if (!error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1626 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
1627 def, NULL, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1628 #endif
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
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 * "copy()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1633 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1634 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1635 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
1636 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1637 item_copy(&argvars[0], rettv, FALSE, 0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1638 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1639
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1640 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1641 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1642 * "cos()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1645 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
1646 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1647 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1648
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1649 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1650 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1651 rettv->vval.v_float = cos(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1652 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1653 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1654 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1655
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1656 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1657 * "cosh()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1658 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1659 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1660 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
1661 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1662 float_T f = 0.0;
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 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1665 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1666 rettv->vval.v_float = cosh(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1667 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1668 rettv->vval.v_float = 0.0;
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1671
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1672 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1673 * "cursor(lnum, col)" function, or
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1674 * "cursor(list)"
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1675 *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1676 * 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
1677 * 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
1678 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1679 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1680 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
1681 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1682 long line, col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1683 long coladd = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1684 int set_curswant = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1685
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1686 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1687 if (argvars[1].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1688 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1689 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1690 colnr_T curswant = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1691
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1692 if (list2fpos(argvars, &pos, NULL, &curswant) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1693 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1694 emsg(_(e_invarg));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1695 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1696 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1697 line = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1698 col = pos.col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1699 coladd = pos.coladd;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1700 if (curswant >= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1701 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1702 curwin->w_curswant = curswant - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1703 set_curswant = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1704 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1705 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1706 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1707 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1708 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
1709 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
1710 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
1711 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
1712 }
6f1c7e9a6393 patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15615
diff changeset
1713 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
1714 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1715 if (line > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1716 curwin->w_cursor.lnum = line;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1717 if (col > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1718 curwin->w_cursor.col = col - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1719 curwin->w_cursor.coladd = coladd;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1720
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1721 /* 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
1722 check_cursor();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1723 /* Correct cursor for multi-byte character. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1724 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1725 mb_adjust_cursor();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1726
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1727 curwin->w_set_curswant = set_curswant;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1728 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1729 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1730
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
1731 #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
1732 /*
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1733 * "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
1734 */
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1735 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
1736 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
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 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
1739
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 = FAIL;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1741 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
1742 if (pid == 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
1743 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
1744 else
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1745 {
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1746 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
1747
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1748 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
1749 {
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1750 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
1751 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
1752 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
1753 }
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1754 }
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1755 }
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1756 #endif
de75c249723d patch 8.1.0091: MS-Windows: Cannot interrupt gdb when program is running
Christian Brabandt <cb@256bit.org>
parents: 14103
diff changeset
1757
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1758 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1759 * "deepcopy()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1762 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
1763 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1764 int noref = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1765 int copyID;
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 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
1768 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
1769 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
1770 emsg(_(e_invarg));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1771 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1772 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1773 copyID = get_copyID();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1774 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
1775 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1776 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1779 * "did_filetype()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1782 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
1783 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1784 rettv->vval.v_number = did_filetype;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1785 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1786
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1787 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1788 * "empty({expr})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1789 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1790 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1791 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
1792 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1793 int n = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1794
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1795 switch (argvars[0].v_type)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1796 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1797 case VAR_STRING:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1798 case VAR_FUNC:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1799 n = argvars[0].vval.v_string == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1800 || *argvars[0].vval.v_string == NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1801 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1802 case VAR_PARTIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1803 n = FALSE;
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_NUMBER:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1806 n = argvars[0].vval.v_number == 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1807 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1808 case VAR_FLOAT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1809 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1810 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
1811 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1812 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1813 case VAR_LIST:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1814 n = argvars[0].vval.v_list == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1815 || 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
1816 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1817 case VAR_DICT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1818 n = argvars[0].vval.v_dict == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1819 || 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
1820 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1821 case VAR_SPECIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1822 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
1823 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1824
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
1825 case VAR_BLOB:
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
1826 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
1827 || 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
1828 break;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
1829
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1830 case VAR_JOB:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1831 #ifdef FEAT_JOB_CHANNEL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1832 n = argvars[0].vval.v_job == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1833 || 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
1834 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1835 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1836 case VAR_CHANNEL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1837 #ifdef FEAT_JOB_CHANNEL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1838 n = argvars[0].vval.v_channel == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1839 || !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
1840 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1841 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1842 case VAR_UNKNOWN:
10359
66f1b5bf3fa6 commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents: 10277
diff changeset
1843 internal_error("f_empty(UNKNOWN)");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1844 n = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1845 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1846 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1847
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1848 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1849 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1850
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1851 /*
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1852 * "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
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 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
1855 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
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 #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
1858 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
1859 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
1860 # 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
1861 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
1862 # else
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1863 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
1864 # endif
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1865
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1866 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
1867 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1868
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1869 # 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
1870 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
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 # else
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1873 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
1874 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1875 # endif
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1876
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1877 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
1878 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1879 # 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
1880 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
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 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
1883 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1884 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
1885 # else
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1886 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
1887 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1888 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
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 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
1891 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1892 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
1893 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1894 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
1895 continue;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1896 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1897 *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
1898 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
1899 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
1900 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1901 #endif
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1902 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1903
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
1904 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1905 * "escape({string}, {chars})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1906 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1907 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1908 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
1909 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1910 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1911
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1912 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
1913 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
1914 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1915 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1918 * "eval()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1921 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
1922 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1923 char_u *s, *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1924
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1925 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
1926 if (s != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1927 s = skipwhite(s);
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 p = s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1930 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
1931 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1932 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
1933 semsg(_(e_invexpr2), p);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1934 need_clr_eos = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1935 rettv->v_type = VAR_NUMBER;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1936 rettv->vval.v_number = 0;
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 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
1939 emsg(_(e_trailing));
9571
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1943 * "eventhandler()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1944 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1945 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1946 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
1947 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1948 rettv->vval.v_number = vgetc_busy;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1949 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1950
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1951 static garray_T redir_execute_ga;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1952
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1953 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1954 * 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
1955 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1956 void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1957 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
1958 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1959 int len;
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 if (value_len == -1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1962 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
1963 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1964 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
1965 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
1966 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1967 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
1968 + redir_execute_ga.ga_len, value, len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1969 redir_execute_ga.ga_len += len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1970 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1971 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1972
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 * Get next line from a list.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1975 * 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
1976 * 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
1977 */
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 static char_u *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1980 get_list_line(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1981 int c UNUSED,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1982 void *cookie,
17178
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17170
diff changeset
1983 int indent UNUSED,
40c4cb095d53 patch 8.1.1588: in :let-heredoc line continuation is recognized
Bram Moolenaar <Bram@vim.org>
parents: 17170
diff changeset
1984 int do_concat UNUSED)
9571
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 listitem_T **p = (listitem_T **)cookie;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1987 listitem_T *item = *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1988 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1989 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1990
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1991 if (item == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1992 return NULL;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
1993 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
1994 *p = item->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1995 return s == NULL ? NULL : vim_strsave(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1996 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1997
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1998 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1999 * "execute()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2000 */
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents: 18008
diff changeset
2001 void
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2002 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
2003 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2004 char_u *cmd = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2005 list_T *list = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2006 int save_msg_silent = msg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2007 int save_emsg_silent = emsg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2008 int save_emsg_noredir = emsg_noredir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2009 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
2010 int save_redir_off = redir_off;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2011 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
2012 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
2013 int echo_output = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2014
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2015 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2016 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2017
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2018 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
2019 {
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2020 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
2021 if (list == NULL || list->lv_first == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2022 /* empty list, no commands, empty output */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2023 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2024 ++list->lv_refcount;
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 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2027 {
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2028 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
2029 if (cmd == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2030 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2031 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2032
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2033 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
2034 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2035 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
2036 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
2037
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2038 if (s == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2039 return;
15121
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
2040 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
2041 echo_output = TRUE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2042 if (STRNCMP(s, "silent", 6) == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2043 ++msg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2044 if (STRCMP(s, "silent!") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2045 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2046 emsg_silent = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2047 emsg_noredir = TRUE;
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 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2050 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2051 ++msg_silent;
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 if (redir_execute)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2054 save_ga = redir_execute_ga;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2055 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
2056 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
2057 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
2058 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
2059 msg_col = 0; // prevent leading spaces
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2060
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2061 if (cmd != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2062 do_cmdline_cmd(cmd);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2063 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2064 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2065 listitem_T *item = list->lv_first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2066
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2067 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
2068 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
2069 --list->lv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2070 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2071
10749
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2072 /* 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
2073 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
2074 {
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2075 ((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
2076 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
2077 }
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2078 else
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2079 {
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2080 ga_clear(&redir_execute_ga);
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2081 rettv->vval.v_string = NULL;
a7789921b514 patch 8.0.0264: memory error reported by ubsan
Christian Brabandt <cb@256bit.org>
parents: 10732
diff changeset
2082 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2083 msg_silent = save_msg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2084 emsg_silent = save_emsg_silent;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2085 emsg_noredir = save_emsg_noredir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2086
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2087 redir_execute = save_redir_execute;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2088 if (redir_execute)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2089 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
2090 redir_off = save_redir_off;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2091
15117
2fed75dee954 patch 8.1.0569: execute() always resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15062
diff changeset
2092 // "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
2093 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
2094 // 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
2095 // "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
2096 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
2097 else
895abc8a5195 patch 8.1.0571: non-silent execute() resets display column to zero
Bram Moolenaar <Bram@vim.org>
parents: 15117
diff changeset
2098 // 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
2099 // 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
2100 msg_col = save_msg_col;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2101 }
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 /*
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2104 * "execute()" function
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2105 */
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2106 static void
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2107 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
2108 {
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2109 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
2110 }
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2111
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2112 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2113 * "exists()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2114 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2115 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2116 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
2117 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2118 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2119 int n = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2120
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2121 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2122 if (*p == '$') /* environment variable */
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 /* first try "normal" environment variables (fast) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2125 if (mch_getenv(p + 1) != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2126 n = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2127 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2128 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2129 /* try expanding things like $VIM and ${HOME} */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2130 p = expand_env_save(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2131 if (p != NULL && *p != '$')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2132 n = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2133 vim_free(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2134 }
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 else if (*p == '&' || *p == '+') /* option */
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 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
2139 if (*skipwhite(p) != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2140 n = FALSE; /* trailing garbage */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2141 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2142 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
2143 {
9717
6226de5f8137 commit https://github.com/vim/vim/commit/b54c3ff3174dbb5dfbfcabdf95200b047beaa644
Christian Brabandt <cb@256bit.org>
parents: 9707
diff changeset
2144 n = function_exists(p + 1, FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2145 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2146 else if (*p == ':')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2147 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2148 n = cmd_exists(p + 1);
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 else if (*p == '#')
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 if (p[1] == '#')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2153 n = autocmd_supported(p + 2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2154 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2155 n = au_exists(p + 1);
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 else /* internal variable */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2158 {
13262
69278c25429d patch 8.0.1505: debugger can't break on a condition
Christian Brabandt <cb@256bit.org>
parents: 13248
diff changeset
2159 n = var_exists(p);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2160 }
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->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2163 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2164
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2165 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2166 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2167 * "exp()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2168 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2169 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2170 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
2171 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2172 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2173
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2174 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2175 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2176 rettv->vval.v_float = exp(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2177 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2178 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2179 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2180 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2181
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2182 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2183 * "expand()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2184 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2185 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2186 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
2187 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2188 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2189 int len;
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
2190 char *errormsg;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2191 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
2192 expand_T xpc;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2193 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2194 char_u *result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2195
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2196 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2197 if (argvars[1].v_type != VAR_UNKNOWN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2198 && 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
2199 && 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
2200 && !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
2201 rettv_list_set(rettv, NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2202
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2203 s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2204 if (*s == '%' || *s == '#' || *s == '<')
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 ++emsg_off;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2207 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
2208 --emsg_off;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2209 if (rettv->v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2210 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2211 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
2212 list_append_string(rettv->vval.v_list, result, -1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2213 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2214 vim_free(result);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2215 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2216 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2217 rettv->vval.v_string = result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2218 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2219 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2220 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2221 /* 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
2222 * 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
2223 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
2224 && 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
2225 options |= WILD_KEEP_ALL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2226 if (!error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2227 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2228 ExpandInit(&xpc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2229 xpc.xp_context = EXPAND_FILES;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2230 if (p_wic)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2231 options += WILD_ICASE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2232 if (rettv->v_type == VAR_STRING)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2233 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
2234 options, WILD_ALL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2235 else if (rettv_list_alloc(rettv) != FAIL)
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 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2238
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2239 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
2240 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
2241 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
2242 ExpandCleanup(&xpc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2243 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2244 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2245 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2246 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2247 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2248 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2249
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2250 /*
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
2251 * "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
2252 * 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
2253 */
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2254 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
2255 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
2256 {
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 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
2258 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
2259 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
2260
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 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
2262 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
2263
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 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
2265 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
2266 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
2267 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
2268 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
2269 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
2270 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
2271
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2272 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
2273 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
2274 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
2275
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2276 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
2277 }
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2278
1841c03a9b5e patch 8.1.1510: a plugin cannot easily expand a command like done internally
Bram Moolenaar <Bram@vim.org>
parents: 17004
diff changeset
2279 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2280 * "feedkeys()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2283 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
2284 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2285 int remap = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2286 int insert = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2287 char_u *keys, *flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2288 char_u nbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2289 int typed = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2290 int execute = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2291 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
2292 int lowlevel = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2293 char_u *keys_esc;
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 /* 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
2296 * 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
2297 * when "sandbox" is no longer set. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2298 if (check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2299 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2300
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2301 keys = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2302
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2303 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2304 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2305 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
2306 for ( ; *flags != NUL; ++flags)
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 switch (*flags)
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 case 'n': remap = FALSE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2311 case 'm': remap = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2312 case 't': typed = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2313 case 'i': insert = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2314 case 'x': execute = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2315 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
2316 case 'L': lowlevel = TRUE; break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2317 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2318 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2319 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2320
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2321 if (*keys != NUL || execute)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2322 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2323 /* 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
2324 * typeahead buffer. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2325 keys_esc = vim_strsave_escape_csi(keys);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2326 if (keys_esc != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2327 {
15615
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2328 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
2329 {
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2330 #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
2331 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
2332 #else
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2333 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
2334 #endif
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2335 }
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2336 else
15687
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
2337 {
15615
536fca2cee19 patch 8.1.0815: dialog for file changed outside of Vim not tested
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
2338 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
2339 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
2340 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
2341 #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
2342 || timer_busy
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
2343 #endif
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
2344 )
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
2345 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
2346 }
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15677
diff changeset
2347 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
2348
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2349 if (execute)
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 int save_msg_scroll = msg_scroll;
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 /* 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
2354 msg_scroll = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2355
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
2356 if (!dangerous)
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
2357 ++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
2358 exec_normal(TRUE, lowlevel, TRUE);
13829
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
2359 if (!dangerous)
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
2360 --ex_normal_busy;
044337cbf854 patch 8.0.1786: no test for 'termwinkey'
Christian Brabandt <cb@256bit.org>
parents: 13796
diff changeset
2361
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2362 msg_scroll |= save_msg_scroll;
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 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2365 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2366 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2367
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2368 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2369 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2370 * "float2nr({float})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2371 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2372 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2373 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
2374 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2375 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2376
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2377 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2378 {
11461
5be73ebf6a15 patch 8.0.0614: float2nr() is not exactly right
Christian Brabandt <cb@256bit.org>
parents: 11418
diff changeset
2379 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
2380 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
2381 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
2382 rettv->vval.v_number = VARNUM_MAX;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2383 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2384 rettv->vval.v_number = (varnumber_T)f;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2385 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2386 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2387
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 * "floor({float})" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2392 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
2393 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2394 float_T f = 0.0;
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 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2397 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2398 rettv->vval.v_float = floor(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2399 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2400 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2401 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2402
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2403 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2404 * "fmod()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2405 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2406 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2407 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
2408 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2409 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
2410
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2411 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2412 if (get_float_arg(argvars, &fx) == OK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2413 && get_float_arg(&argvars[1], &fy) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2414 rettv->vval.v_float = fmod(fx, fy);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2415 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2416 rettv->vval.v_float = 0.0;
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2419
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 * "fnameescape({string})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2422 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2423 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2424 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
2425 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2426 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
2427 tv_get_string(&argvars[0]), FALSE);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2428 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2429 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2430
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2431 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2432 * "foreground()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2433 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2434 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2435 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
2436 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2437 #ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2438 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
2439 {
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2440 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
2441 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
2442 }
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
2443 #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
2444 #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
2445 win32_set_foreground();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2446 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2447 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2448
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2449 static void
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2450 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
2451 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2452 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2453 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2454 int use_string = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2455 partial_T *arg_pt = NULL;
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2456 char_u *trans_name = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2457
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2458 if (argvars[0].v_type == VAR_FUNC)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2459 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2460 /* function(MyFunc, [arg], dict) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2461 s = argvars[0].vval.v_string;
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 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
2464 && argvars[0].vval.v_partial != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2465 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2466 /* function(dict.MyFunc, [arg]) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2467 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
2468 s = partial_name(arg_pt);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2469 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2470 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2471 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2472 /* 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
2473 s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2474 use_string = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2475 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2476
9919
885e3c9c0e10 commit https://github.com/vim/vim/commit/843b884461de1c79a1d2748549776fb13fc94360
Christian Brabandt <cb@256bit.org>
parents: 9904
diff changeset
2477 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
2478 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2479 name = s;
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2480 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
2481 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
2482 if (*name != NUL)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2483 s = NULL;
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2484 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2485
9919
885e3c9c0e10 commit https://github.com/vim/vim/commit/843b884461de1c79a1d2748549776fb13fc94360
Christian Brabandt <cb@256bit.org>
parents: 9904
diff changeset
2486 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
2487 || (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
2488 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
2489 /* 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
2490 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
2491 ? find_func(trans_name) == NULL
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2492 : !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
2493 semsg(_("E700: Unknown function: %s"), s);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2494 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2495 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2496 int dict_idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2497 int arg_idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2498 list_T *list = 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 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
2501 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2502 char sid_buf[25];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2503 int off = *s == 's' ? 2 : 5;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2504
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2505 /* 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
2506 * 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
2507 * 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
2508 * 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
2509 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
2510 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
2511 if (name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2512 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2513 STRCPY(name, sid_buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2514 STRCAT(name, s + off);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2515 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2516 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2517 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2518 name = vim_strsave(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2519
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2520 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2521 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2522 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2523 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2524 /* function(name, [args], dict) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2525 arg_idx = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2526 dict_idx = 2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2527 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2528 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
2529 /* function(name, dict) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2530 dict_idx = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2531 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2532 /* function(name, [args]) */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2533 arg_idx = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2534 if (dict_idx > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2535 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2536 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
2537 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
2538 emsg(_("E922: expected a dict"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2539 vim_free(name);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2540 goto theend;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2541 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2542 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
2543 dict_idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2544 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2545 if (arg_idx > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2546 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2547 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
2548 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
2549 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
2550 vim_free(name);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2551 goto theend;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2552 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2553 list = argvars[arg_idx].vval.v_list;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2554 if (list == NULL || list->lv_len == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2555 arg_idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2556 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2557 }
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2558 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
2559 {
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
2560 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
2561
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2562 /* result is a VAR_PARTIAL */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2563 if (pt == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2564 vim_free(name);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2565 else
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_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
2568 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2569 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2570 int i = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2571 int arg_len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2572 int lv_len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2573
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2574 if (arg_pt != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2575 arg_len = arg_pt->pt_argc;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2576 if (list != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2577 lv_len = list->lv_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2578 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
2579 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
2580 if (pt->pt_argv == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2581 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2582 vim_free(pt);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2583 vim_free(name);
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2584 goto theend;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2585 }
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2586 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
2587 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
2588 if (lv_len > 0)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2589 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
2590 li = li->li_next)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2591 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
2592 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2593
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2594 /* 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
2595 * use "dict". That is backwards compatible. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2596 if (dict_idx > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2597 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2598 /* 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
2599 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
2600 ++pt->pt_dict->dv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2601 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2602 else if (arg_pt != NULL)
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 /* 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
2605 * bound automatically. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2606 pt->pt_dict = arg_pt->pt_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2607 pt->pt_auto = arg_pt->pt_auto;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2608 if (pt->pt_dict != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2609 ++pt->pt_dict->dv_refcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2610 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2611
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2612 pt->pt_refcount = 1;
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2613 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
2614 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2615 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
2616 func_ptr_ref(pt->pt_func);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2617 vim_free(name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2618 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2619 else if (is_funcref)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2620 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2621 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
2622 func_ptr_ref(pt->pt_func);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2623 vim_free(name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2624 }
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2625 else
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2626 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2627 pt->pt_name = name;
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2628 func_ref(name);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2629 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2630 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2631 rettv->v_type = VAR_PARTIAL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2632 rettv->vval.v_partial = pt;
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 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2635 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2636 /* result is a VAR_FUNC */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2637 rettv->v_type = VAR_FUNC;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2638 rettv->vval.v_string = name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2639 func_ref(name);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2640 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2641 }
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2642 theend:
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2643 vim_free(trans_name);
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
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 * "funcref()" function
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 static void
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2650 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
2651 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2652 common_function(argvars, rettv, TRUE);
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
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2655 /*
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2656 * "function()" function
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2657 */
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2658 static void
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2659 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
2660 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2661 common_function(argvars, rettv, FALSE);
9571
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2664 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2665 * "garbagecollect()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2666 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2667 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2668 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
2669 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2670 /* 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
2671 * 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
2672 want_garbage_collect = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2673
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2674 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
2675 garbage_collect_at_exit = TRUE;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2678 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2679 * "get()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2680 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2681 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2682 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
2683 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2684 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2685 list_T *l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2686 dictitem_T *di;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2687 dict_T *d;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2688 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
2689 int what_is_dict = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2690
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2691 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
2692 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2693 int error = FALSE;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2694 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
2695
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2696 if (!error)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2697 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2698 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
2699 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
2700 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
2701 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
2702 rettv->vval.v_number = -1;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2703 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
2704 {
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2705 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
2706 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
2707 }
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2708 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2709 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
2710 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
2711 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2712 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
2713 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2714 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2715
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2716 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
2717 if (!error && li != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2718 tv = &li->li_tv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2719 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2720 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2721 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
2722 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2723 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
2724 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2725 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
2726 if (di != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2727 tv = &di->di_tv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2728 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2729 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2730 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
2731 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2732 partial_T *pt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2733 partial_T fref_pt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2734
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2735 if (argvars[0].v_type == VAR_PARTIAL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2736 pt = argvars[0].vval.v_partial;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2737 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2738 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2739 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
2740 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
2741 pt = &fref_pt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2742 }
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 if (pt != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2745 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2746 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
2747 char_u *n;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2748
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2749 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
2750 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2751 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
2752 n = partial_name(pt);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2753 if (n == NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2754 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2755 else
9723
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2756 {
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2757 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
2758 if (rettv->v_type == VAR_FUNC)
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2759 func_ref(rettv->vval.v_string);
80ac9cf77c9b commit https://github.com/vim/vim/commit/437bafe4c8a83ed71ee006eda7f54b65a90f0d4c
Christian Brabandt <cb@256bit.org>
parents: 9717
diff changeset
2760 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2761 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2762 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
2763 {
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
2764 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
2765 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
2766 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
2767 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2768 else if (STRCMP(what, "args") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2769 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2770 rettv->v_type = VAR_LIST;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2771 if (rettv_list_alloc(rettv) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2772 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2773 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2774
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2775 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
2776 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
2777 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2778 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2779 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
2780 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
2781
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
2782 // 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
2783 // third argument
2b4c138bf8e9 patch 8.1.1765: get(func, dict, def) does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 17530
diff changeset
2784 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
2785 return;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2786 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2787 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2788 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
2789 semsg(_(e_listdictblobarg), "get()");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2790
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2791 if (tv == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2792 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2793 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2794 copy_tv(&argvars[2], rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2795 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2796 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2797 copy_tv(tv, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2798 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2799
9858
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9850
diff changeset
2800 /*
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2801 * "getchangelist()" function
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2802 */
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2803 static void
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2804 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
2805 {
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2806 #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
2807 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
2808 int i;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2809 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
2810 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
2811 #endif
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2812
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2813 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
2814 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2815
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2816 #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
2817 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
2818 buf = curbuf;
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2819 else
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2820 {
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2821 (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
2822 ++emsg_off;
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2823 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
2824 --emsg_off;
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17855
diff changeset
2825 }
13280
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2826 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
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 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
2830 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
2831 return;
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 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
2834 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2835 /*
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2836 * 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
2837 * 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
2838 * 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
2839 */
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2840 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
2841 (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
2842 ? 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
2843
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2844 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
2845 {
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2846 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
2847 continue;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2848 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
2849 return;
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2850 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
2851 return;
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
2852 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
2853 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
2854 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
2855 }
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2856 #endif
fbda23eb0996 patch 8.0.1514: getting the list of changes is not easy
Christian Brabandt <cb@256bit.org>
parents: 13278
diff changeset
2857 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2858
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 * "getcharsearch()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2861 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2862 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2863 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
2864 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2865 if (rettv_dict_alloc(rettv) != FAIL)
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 dict_T *dict = rettv->vval.v_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2868
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
2869 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
2870 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
2871 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
2872 }
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2875 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2876 * "getcmdwintype()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2877 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2878 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2879 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
2880 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2881 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2882 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2883 #ifdef FEAT_CMDWIN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2884 rettv->vval.v_string = alloc(2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2885 if (rettv->vval.v_string != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2886 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2887 rettv->vval.v_string[0] = cmdwin_type;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2888 rettv->vval.v_string[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2889 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2890 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2891 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2892
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2893 /*
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2894 * "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
2895 */
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2896 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
2897 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
2898 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2899 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
2900 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
2901
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2902 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
2903 {
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_SPECIAL;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2905 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
2906 return;
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2907 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2908 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
2909 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
2910 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
2911 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
2912 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2913
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
2914 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2915 * "getfontname()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2916 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2917 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2918 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
2919 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2920 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2921 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2922 #ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2923 if (gui.in_use)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2924 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2925 GuiFont font;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2926 char_u *name = NULL;
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 if (argvars[0].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2929 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2930 /* 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
2931 * 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
2932 font = gui.norm_font;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2933 name = hl_get_font_name();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2934 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2935 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2936 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
2937 name = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2938 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
2939 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2940 font = gui_mch_get_font(name, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2941 if (font == NOFONT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2942 return; /* Invalid font name, return empty string. */
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 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
2945 if (argvars[0].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2946 gui_mch_free_font(font);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2947 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2948 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2949 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2950
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2951 /*
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
2952 * "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
2953 */
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 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
2955 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
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 #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
2958 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
2959 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
2960 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
2961 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
2962 #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
2963
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 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
2965 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
2966
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 #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
2968 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
2969 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
2970 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
2971
15788
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
2972 cleanup_jumplist(wp, TRUE);
c24572e66556 patch 8.1.0901: index in getjumplist() may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 15780
diff changeset
2973
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
2974 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
2975 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
2976 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
2977
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2978 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
2979 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
2980 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
2981
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 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
2983 {
13248
5958573d8a72 patch 8.0.1498: getjumplist() returns duplicate entries
Christian Brabandt <cb@256bit.org>
parents: 13246
diff changeset
2984 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
2985 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
2986 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
2987 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
2988 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
2989 return;
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14214
diff changeset
2990 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
2991 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
2992 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
2993 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
2994 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
2995 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
2996 }
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2997 #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
2998 }
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
2999
dd3b2ecf91f6 patch 8.0.1497: getting the jump list requires parsing the output of :jumps
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
3000 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3001 * "getpid()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3002 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3003 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3004 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
3005 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3006 rettv->vval.v_number = mch_get_pid();
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3009 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3010 getpos_both(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3011 typval_T *argvars,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3012 typval_T *rettv,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3013 int getcurpos)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3014 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3015 pos_T *fp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3016 list_T *l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3017 int fnum = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3018
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3019 if (rettv_list_alloc(rettv) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3020 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3021 l = rettv->vval.v_list;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3022 if (getcurpos)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3023 fp = &curwin->w_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3024 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3025 fp = var2fpos(&argvars[0], TRUE, &fnum);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3026 if (fnum != -1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3027 list_append_number(l, (varnumber_T)fnum);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3028 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3029 list_append_number(l, (varnumber_T)0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3030 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
3031 : (varnumber_T)0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3032 list_append_number(l, (fp != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3033 ? (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
3034 : (varnumber_T)0);
15636
6f1c7e9a6393 patch 8.1.0826: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15615
diff changeset
3035 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
3036 (varnumber_T)0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3037 if (getcurpos)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3038 {
15985
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3039 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
3040 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
3041 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
3042
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3043 update_curswant();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3044 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
3045 (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
3046
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3047 // 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
3048 // function has a side effect.
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3049 if (save_set_curswant)
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3050 {
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3051 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
3052 curwin->w_curswant = save_curswant;
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3053 curwin->w_virtcol = save_virtcol;
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3054 curwin->w_valid &= ~VALID_VIRTCOL;
e91750e8adb5 patch 8.1.0998: getcurpos() unexpectedly changes "curswant"
Bram Moolenaar <Bram@vim.org>
parents: 15979
diff changeset
3055 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3056 }
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 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3059 rettv->vval.v_number = FALSE;
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
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 * "getcurpos()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3066 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
3067 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3068 getpos_both(argvars, rettv, TRUE);
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
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 * "getpos(string)" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3075 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
3076 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3077 getpos_both(argvars, rettv, FALSE);
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3080 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3081 * "getreg()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3082 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3083 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3084 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
3085 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3086 char_u *strregname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3087 int regname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3088 int arg2 = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3089 int return_list = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3090 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3091
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3092 if (argvars[0].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3093 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3094 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
3095 error = strregname == NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3096 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3097 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3098 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
3099 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
3100 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
3101 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3102 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3103 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3104 strregname = get_vim_var_str(VV_REG);
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 (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3107 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3108
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3109 regname = (strregname == NULL ? '"' : *strregname);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3110 if (regname == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3111 regname = '"';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3112
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3113 if (return_list)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3114 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3115 rettv->v_type = VAR_LIST;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3116 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
3117 (arg2 ? GREG_EXPR_SRC : 0) | GREG_LIST);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3118 if (rettv->vval.v_list == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3119 (void)rettv_list_alloc(rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3120 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3121 ++rettv->vval.v_list->lv_refcount;
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 else
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 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3126 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
3127 arg2 ? GREG_EXPR_SRC : 0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3128 }
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3131 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3132 * "getregtype()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3133 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3134 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3135 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
3136 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3137 char_u *strregname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3138 int regname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3139 char_u buf[NUMBUFLEN + 2];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3140 long reglen = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3141
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3142 if (argvars[0].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3143 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3144 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
3145 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
3146 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3147 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3148 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3149 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3150 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3151 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3152 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3153 /* Default to v:register */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3154 strregname = get_vim_var_str(VV_REG);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3155
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3156 regname = (strregname == NULL ? '"' : *strregname);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3157 if (regname == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3158 regname = '"';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3159
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3160 buf[0] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3161 buf[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3162 switch (get_reg_type(regname, &reglen))
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 case MLINE: buf[0] = 'V'; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3165 case MCHAR: buf[0] = 'v'; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3166 case MBLOCK:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3167 buf[0] = Ctrl_V;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3168 sprintf((char *)buf + 1, "%ld", reglen + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3169 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3170 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3171 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3172 rettv->vval.v_string = vim_strsave(buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3173 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3174
9858
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9850
diff changeset
3175 /*
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3176 * "gettagstack()" function
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3177 */
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3178 static void
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3179 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
3180 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3181 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
3182
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3183 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
3184 return;
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 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
3187 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3188 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
3189 if (wp == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3190 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3191 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3192
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3193 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
3194 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
3195
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3196 /* for VIM_VERSION_ defines */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3197 #include "version.h"
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3198
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3199 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3200 * "has()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3201 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3202 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3203 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
3204 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3205 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3206 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3207 int n = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3208 static char *(has_list[]) =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3209 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3210 #ifdef AMIGA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3211 "amiga",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3212 # ifdef FEAT_ARP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3213 "arp",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3214 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3215 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3216 #ifdef __BEOS__
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3217 "beos",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3218 #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
3219 #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
3220 "bsd",
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3221 #endif
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3222 #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
3223 "hpux",
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3224 #endif
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3225 #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
3226 "linux",
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3227 #endif
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12564
diff changeset
3228 #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
3229 "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
3230 "osx", /* Mac OS X */
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12564
diff changeset
3231 # 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
3232 "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
3233 "osxdarwin", /* synonym for macunix */
12716
351cf7c67bbe patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents: 12564
diff changeset
3234 # endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3235 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3236 #ifdef __QNX__
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3237 "qnx",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3238 #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
3239 #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
3240 "sun",
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3241 #else
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3242 "moon",
772e72b046a3 patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents: 15636
diff changeset
3243 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3244 #ifdef UNIX
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3245 "unix",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3246 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3247 #ifdef VMS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3248 "vms",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3249 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3250 #ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3251 "win32",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3252 #endif
15955
907481b9260f patch 8.1.0983: checking __CYGWIN32__ unnecessarily
Bram Moolenaar <Bram@vim.org>
parents: 15890
diff changeset
3253 #if defined(UNIX) && defined(__CYGWIN__)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3254 "win32unix",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3255 #endif
15890
de2c2a378cd1 patch 8.1.0951: using WIN64 even though it is never defined
Bram Moolenaar <Bram@vim.org>
parents: 15868
diff changeset
3256 #ifdef _WIN64
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3257 "win64",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3258 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3259 #ifdef EBCDIC
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3260 "ebcdic",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3261 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3262 #ifndef CASE_INSENSITIVE_FILENAME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3263 "fname_case",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3264 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3265 #ifdef HAVE_ACL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3266 "acl",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3267 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3268 #ifdef FEAT_ARABIC
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3269 "arabic",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3270 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3271 "autocmd",
14399
e7d1bc5ee3b8 patch 8.1.0214: +autochdir feature not reported by has() or :version
Christian Brabandt <cb@256bit.org>
parents: 14393
diff changeset
3272 #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
3273 "autochdir",
14399
e7d1bc5ee3b8 patch 8.1.0214: +autochdir feature not reported by has() or :version
Christian Brabandt <cb@256bit.org>
parents: 14393
diff changeset
3274 #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
3275 #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
3276 "autoservername",
963cdeb42c41 patch 8.0.1295: cannot automatically get a server name in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12794
diff changeset
3277 #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
3278 #ifdef FEAT_BEVAL_GUI
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3279 "balloon_eval",
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3280 # 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
3281 "balloon_multiline",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3282 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3283 #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
3284 #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
3285 "balloon_eval_term",
ebb4f6c93598 patch 8.0.1309: cannot use 'balloonexpr' in a terminal
Christian Brabandt <cb@256bit.org>
parents: 12857
diff changeset
3286 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3287 #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
3288 "builtin_terms",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3289 # ifdef ALL_BUILTIN_TCAPS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3290 "all_builtin_terms",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3291 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3292 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3293 #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
3294 || defined(FEAT_GUI_MSWIN) \
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3295 || defined(FEAT_GUI_MOTIF))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3296 "browsefilter",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3297 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3298 #ifdef FEAT_BYTEOFF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3299 "byte_offset",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3300 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3301 #ifdef FEAT_JOB_CHANNEL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3302 "channel",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3303 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3304 #ifdef FEAT_CINDENT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3305 "cindent",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3306 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3307 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3308 "clientserver",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3309 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3310 #ifdef FEAT_CLIPBOARD
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3311 "clipboard",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3312 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3313 "cmdline_compl",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3314 "cmdline_hist",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3315 #ifdef FEAT_COMMENTS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3316 "comments",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3317 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3318 #ifdef FEAT_CONCEAL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3319 "conceal",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3320 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3321 #ifdef FEAT_CRYPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3322 "cryptv",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3323 "crypt-blowfish",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3324 "crypt-blowfish2",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3325 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3326 #ifdef FEAT_CSCOPE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3327 "cscope",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3328 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3329 "cursorbind",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3330 #ifdef CURSOR_SHAPE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3331 "cursorshape",
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 DEBUG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3334 "debug",
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_CON_DIALOG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3337 "dialog_con",
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_GUI_DIALOG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3340 "dialog_gui",
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_DIFF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3343 "diff",
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_DIGRAPHS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3346 "digraphs",
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 #ifdef FEAT_DIRECTX
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3349 "directx",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3350 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3351 #ifdef FEAT_DND
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3352 "dnd",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3353 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3354 #ifdef FEAT_EMACS_TAGS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3355 "emacs_tags",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3356 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3357 "eval", /* always present, of course! */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3358 "ex_extra", /* graduated feature */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3359 #ifdef FEAT_SEARCH_EXTRA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3360 "extra_search",
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_SEARCHPATH
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3363 "file_in_path",
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_FILTERPIPE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3366 "filterpipe",
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_FIND_ID
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3369 "find_in_path",
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 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3372 "float",
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_FOLDING
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3375 "folding",
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_FOOTER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3378 "footer",
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 #if !defined(USE_SYSTEM) && defined(UNIX)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3381 "fork",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3382 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3383 #ifdef FEAT_GETTEXT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3384 "gettext",
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 #ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3387 "gui",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3388 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3389 #ifdef FEAT_GUI_ATHENA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3390 # ifdef FEAT_GUI_NEXTAW
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3391 "gui_neXtaw",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3392 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3393 "gui_athena",
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3396 #ifdef FEAT_GUI_GTK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3397 "gui_gtk",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3398 # ifdef USE_GTK3
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3399 "gui_gtk3",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3400 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3401 "gui_gtk2",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3402 # endif
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_GNOME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3405 "gui_gnome",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3406 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3407 #ifdef FEAT_GUI_MAC
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3408 "gui_mac",
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 #ifdef FEAT_GUI_MOTIF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3411 "gui_motif",
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 #ifdef FEAT_GUI_PHOTON
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3414 "gui_photon",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3415 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3416 #ifdef FEAT_GUI_MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3417 "gui_win32",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3418 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3419 #ifdef FEAT_HANGULIN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3420 "hangul_input",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3421 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3422 #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
3423 "iconv",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3424 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3425 "insert_expand",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3426 #ifdef FEAT_JOB_CHANNEL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3427 "job",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3428 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3429 #ifdef FEAT_JUMPLIST
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3430 "jumplist",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3431 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3432 #ifdef FEAT_KEYMAP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3433 "keymap",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3434 #endif
9690
4a7a88404076 commit https://github.com/vim/vim/commit/9532fe7fbe1b14531931e83bd9f8054efdcf7509
Christian Brabandt <cb@256bit.org>
parents: 9672
diff changeset
3435 "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
3436 #ifdef FEAT_LANGMAP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3437 "langmap",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3438 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3439 #ifdef FEAT_LIBCALL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3440 "libcall",
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 #ifdef FEAT_LINEBREAK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3443 "linebreak",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3444 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3445 #ifdef FEAT_LISP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3446 "lispindent",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3447 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3448 "listcmds",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3449 "localmap",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3450 #ifdef FEAT_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3451 # ifndef DYNAMIC_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3452 "lua",
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3455 #ifdef FEAT_MENU
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3456 "menu",
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_SESSION
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3459 "mksession",
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 "modify_fname",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3462 #ifdef FEAT_MOUSE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3463 "mouse",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3464 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3465 #ifdef FEAT_MOUSESHAPE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3466 "mouseshape",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3467 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3468 #if defined(UNIX) || defined(VMS)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3469 # ifdef FEAT_MOUSE_DEC
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3470 "mouse_dec",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3471 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3472 # ifdef FEAT_MOUSE_GPM
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3473 "mouse_gpm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3474 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3475 # ifdef FEAT_MOUSE_JSB
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3476 "mouse_jsbterm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3477 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3478 # ifdef FEAT_MOUSE_NET
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3479 "mouse_netterm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3480 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3481 # ifdef FEAT_MOUSE_PTERM
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3482 "mouse_pterm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3483 # endif
16058
012f03e583e2 patch 8.1.1034: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15985
diff changeset
3484 # ifdef FEAT_MOUSE_XTERM
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3485 "mouse_sgr",
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_SYSMOUSE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3488 "mouse_sysmouse",
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_MOUSE_URXVT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3491 "mouse_urxvt",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3492 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3493 # ifdef FEAT_MOUSE_XTERM
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3494 "mouse_xterm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3495 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3496 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3497 "multi_byte",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3498 #ifdef FEAT_MBYTE_IME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3499 "multi_byte_ime",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3500 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3501 #ifdef FEAT_MULTI_LANG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3502 "multi_lang",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3503 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3504 #ifdef FEAT_MZSCHEME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3505 #ifndef DYNAMIC_MZSCHEME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3506 "mzscheme",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3507 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3508 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3509 #ifdef FEAT_NUM64
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3510 "num64",
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_OLE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3513 "ole",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3514 #endif
14375
e5d7dd985b53 patch 8.1.0202: :version always shows +packages
Christian Brabandt <cb@256bit.org>
parents: 14368
diff changeset
3515 #ifdef FEAT_EVAL
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3516 "packages",
14375
e5d7dd985b53 patch 8.1.0202: :version always shows +packages
Christian Brabandt <cb@256bit.org>
parents: 14368
diff changeset
3517 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3518 #ifdef FEAT_PATH_EXTRA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3519 "path_extra",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3520 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3521 #ifdef FEAT_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3522 #ifndef DYNAMIC_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3523 "perl",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3524 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3525 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3526 #ifdef FEAT_PERSISTENT_UNDO
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3527 "persistent_undo",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3528 #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
3529 #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
3530 "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
3531 # 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
3532 "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
3533 # else
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3534 "python",
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
3535 "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
3536 # endif
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3537 #endif
aaead5b4d77d patch 8.0.1436: not enough information about what Python version may work
Christian Brabandt <cb@256bit.org>
parents: 13101
diff changeset
3538 #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
3539 "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
3540 # 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
3541 "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
3542 # else
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3543 "python3",
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
3544 "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
3545 # endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3546 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3547 #ifdef FEAT_POSTSCRIPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3548 "postscript",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3549 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3550 #ifdef FEAT_PRINTER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3551 "printer",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3552 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3553 #ifdef FEAT_PROFILE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3554 "profile",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3555 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3556 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3557 "reltime",
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_QUICKFIX
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3560 "quickfix",
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_RIGHTLEFT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3563 "rightleft",
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 #if defined(FEAT_RUBY) && !defined(DYNAMIC_RUBY)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3566 "ruby",
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 "scrollbind",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3569 #ifdef FEAT_CMDL_INFO
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3570 "showcmd",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3571 "cmdline_info",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3572 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3573 #ifdef FEAT_SIGNS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3574 "signs",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3575 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3576 #ifdef FEAT_SMARTINDENT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3577 "smartindent",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3578 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3579 #ifdef STARTUPTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3580 "startuptime",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3581 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3582 #ifdef FEAT_STL_OPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3583 "statusline",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3584 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3585 #ifdef FEAT_NETBEANS_INTG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3586 "netbeans_intg",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3587 #endif
17004
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
3588 #ifdef FEAT_SOUND
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
3589 "sound",
353ed7ef78df patch 8.1.1502: cannot play any sound
Bram Moolenaar <Bram@vim.org>
parents: 16890
diff changeset
3590 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3591 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3592 "spell",
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_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3595 "syntax",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3596 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3597 #if defined(USE_SYSTEM) || !defined(UNIX)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3598 "system",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3599 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3600 #ifdef FEAT_TAG_BINS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3601 "tag_binary",
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_TCL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3604 # ifndef DYNAMIC_TCL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3605 "tcl",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3606 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3607 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3608 #ifdef FEAT_TERMGUICOLORS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3609 "termguicolors",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3610 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3611 #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
3612 "terminal",
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
3613 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3614 #ifdef TERMINFO
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3615 "terminfo",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3616 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3617 #ifdef FEAT_TERMRESPONSE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3618 "termresponse",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3619 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3620 #ifdef FEAT_TEXTOBJ
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3621 "textobjects",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3622 #endif
15138
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
3623 #ifdef FEAT_TEXT_PROP
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
3624 "textprop",
9df130fd5e0d patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents: 15121
diff changeset
3625 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3626 #ifdef HAVE_TGETENT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3627 "tgetent",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3628 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3629 #ifdef FEAT_TIMERS
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3630 "timers",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3631 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3632 #ifdef FEAT_TITLE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3633 "title",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3634 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3635 #ifdef FEAT_TOOLBAR
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3636 "toolbar",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3637 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3638 #if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3639 "unnamedplus",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3640 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3641 "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
3642 "user_commands",
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14161
diff changeset
3643 #ifdef FEAT_VARTABS
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14161
diff changeset
3644 "vartabs",
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14161
diff changeset
3645 #endif
16223
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16213
diff changeset
3646 "vertsplit",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3647 #ifdef FEAT_VIMINFO
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3648 "viminfo",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3649 #endif
16223
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16213
diff changeset
3650 "vimscript-1",
abb67309c1ca patch 8.1.1116: cannot enforce a Vim script style
Bram Moolenaar <Bram@vim.org>
parents: 16213
diff changeset
3651 "vimscript-2",
16370
235a2b941498 patch 8.1.1190: has('vimscript-3') does not work
Bram Moolenaar <Bram@vim.org>
parents: 16362
diff changeset
3652 "vimscript-3",
18086
9d6832a5426f patch 8.1.2038: has('vimscript-4') is always 0
Bram Moolenaar <Bram@vim.org>
parents: 18080
diff changeset
3653 "vimscript-4",
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3654 "virtualedit",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3655 "visual",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3656 "visualextra",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3657 "vreplace",
13454
1720b96e53b6 patch 8.0.1601: highlight test fails on Win32
Christian Brabandt <cb@256bit.org>
parents: 13438
diff changeset
3658 #ifdef FEAT_VTP
1720b96e53b6 patch 8.0.1601: highlight test fails on Win32
Christian Brabandt <cb@256bit.org>
parents: 13438
diff changeset
3659 "vtp",
1720b96e53b6 patch 8.0.1601: highlight test fails on Win32
Christian Brabandt <cb@256bit.org>
parents: 13438
diff changeset
3660 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3661 #ifdef FEAT_WILDIGN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3662 "wildignore",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3663 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3664 #ifdef FEAT_WILDMENU
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3665 "wildmenu",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3666 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3667 "windows",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3668 #ifdef FEAT_WAK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3669 "winaltkeys",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3670 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3671 #ifdef FEAT_WRITEBACKUP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3672 "writebackup",
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 FEAT_XIM
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3675 "xim",
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 FEAT_XFONTSET
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3678 "xfontset",
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_XPM_W32
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3681 "xpm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3682 "xpm_w32", /* for backward compatibility */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3683 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3684 # if defined(HAVE_XPM)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3685 "xpm",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3686 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3687 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3688 #ifdef USE_XSMP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3689 "xsmp",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3690 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3691 #ifdef USE_XSMP_INTERACT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3692 "xsmp_interact",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3693 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3694 #ifdef FEAT_XCLIPBOARD
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3695 "xterm_clipboard",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3696 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3697 #ifdef FEAT_XTERM_SAVE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3698 "xterm_save",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3699 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3700 #if defined(UNIX) && defined(FEAT_X11)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3701 "X11",
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3702 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3703 NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3704 };
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3705
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3706 name = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3707 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
3708 if (STRICMP(name, has_list[i]) == 0)
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 n = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3711 break;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3714 if (n == FALSE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3715 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3716 if (STRNICMP(name, "patch", 5) == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3717 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3718 if (name[5] == '-'
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3719 && STRLEN(name) >= 11
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3720 && vim_isdigit(name[6])
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3721 && vim_isdigit(name[8])
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3722 && vim_isdigit(name[10]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3723 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3724 int major = atoi((char *)name + 6);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3725 int minor = atoi((char *)name + 8);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3726
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3727 /* Expect "patch-9.9.01234". */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3728 n = (major < VIM_VERSION_MAJOR
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3729 || (major == VIM_VERSION_MAJOR
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3730 && (minor < VIM_VERSION_MINOR
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3731 || (minor == VIM_VERSION_MINOR
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3732 && has_patch(atoi((char *)name + 10))))));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3733 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3734 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3735 n = has_patch(atoi((char *)name + 5));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3736 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3737 else if (STRICMP(name, "vim_starting") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3738 n = (starting != 0);
10404
65e0537a4560 commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
3739 else if (STRICMP(name, "ttyin") == 0)
65e0537a4560 commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
3740 n = mch_input_isatty();
65e0537a4560 commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
3741 else if (STRICMP(name, "ttyout") == 0)
65e0537a4560 commit https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
3742 n = stdout_isatty;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3743 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
3744 n = has_mbyte;
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3745 #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
3746 else if (STRICMP(name, "balloon_multiline") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3747 n = multiline_balloon_available();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3748 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3749 #ifdef DYNAMIC_TCL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3750 else if (STRICMP(name, "tcl") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3751 n = tcl_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3752 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3753 #if defined(USE_ICONV) && defined(DYNAMIC_ICONV)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3754 else if (STRICMP(name, "iconv") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3755 n = iconv_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3756 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3757 #ifdef DYNAMIC_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3758 else if (STRICMP(name, "lua") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3759 n = lua_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3760 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3761 #ifdef DYNAMIC_MZSCHEME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3762 else if (STRICMP(name, "mzscheme") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3763 n = mzscheme_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3764 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3765 #ifdef DYNAMIC_RUBY
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3766 else if (STRICMP(name, "ruby") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3767 n = ruby_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3768 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3769 #ifdef DYNAMIC_PYTHON
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3770 else if (STRICMP(name, "python") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3771 n = python_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3772 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3773 #ifdef DYNAMIC_PYTHON3
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3774 else if (STRICMP(name, "python3") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3775 n = python3_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3776 #endif
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
3777 #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
3778 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
3779 {
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
3780 # 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
3781 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
3782 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
3783 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
3784 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
3785 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
3786 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
3787 # 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
3788 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
3789 # 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
3790 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
3791 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
3792 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3793 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3794 #ifdef DYNAMIC_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3795 else if (STRICMP(name, "perl") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3796 n = perl_enabled(FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3797 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3798 #ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3799 else if (STRICMP(name, "gui_running") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3800 n = (gui.in_use || gui.starting);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3801 # ifdef FEAT_BROWSE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3802 else if (STRICMP(name, "browse") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3803 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
3804 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3805 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3806 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3807 else if (STRICMP(name, "syntax_items") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3808 n = syntax_present(curwin);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3809 #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
3810 #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
3811 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
3812 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
3813 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3814 #ifdef FEAT_NETBEANS_INTG
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3815 else if (STRICMP(name, "netbeans_enabled") == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3816 n = netbeans_active();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3817 #endif
16527
5412fcd03ecb patch 8.1.1267: cannot check if GPM mouse support is working
Bram Moolenaar <Bram@vim.org>
parents: 16517
diff changeset
3818 #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
3819 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
3820 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
3821 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3822 #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
3823 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
3824 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
3825 #endif
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
3826 #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
3827 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
3828 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
3829 #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
3830 #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
3831 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
3832 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
3833 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3834 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3835
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3836 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3837 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3838
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3839 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3840 * "haslocaldir()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3841 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3842 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3843 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
3844 {
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
3845 tabpage_T *tp = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3846 win_T *wp = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3847
16427
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
3848 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
3849
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
3850 // 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
3851 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
3852 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
3853 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
3854 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
3855 else
8c3a1bd270bb patch 8.1.1218: cannot set a directory for a tab page
Bram Moolenaar <Bram@vim.org>
parents: 16411
diff changeset
3856 rettv->vval.v_number = 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3857 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3858
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3859 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3860 * "hasmapto()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3861 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3862 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3863 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
3864 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3865 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3866 char_u *mode;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3867 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3868 int abbr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3869
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3870 name = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3871 if (argvars[1].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3872 mode = (char_u *)"nvo";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3873 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3874 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3875 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
3876 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
3877 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
3878 }
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 if (map_to_exists(name, mode, abbr))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3881 rettv->vval.v_number = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3882 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3883 rettv->vval.v_number = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3884 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3885
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3886 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3887 * "highlightID(name)" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3890 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
3891 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3892 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
3893 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3894
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 * "highlight_exists()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3899 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
3900 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3901 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
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3905 * "hostname()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3906 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3907 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3908 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
3909 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3910 char_u hostname[256];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3911
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3912 mch_get_host_name(hostname, 256);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3913 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3914 rettv->vval.v_string = vim_strsave(hostname);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3915 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3916
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3917 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3918 * iconv() function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3919 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3920 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3921 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
3922 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3923 char_u buf1[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3924 char_u buf2[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3925 char_u *from, *to, *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3926 vimconv_T vimconv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3927
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3928 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3929 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3930
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3931 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
3932 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
3933 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
3934 vimconv.vc_type = CONV_NONE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3935 convert_setup(&vimconv, from, to);
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 /* 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
3938 if (vimconv.vc_type == CONV_NONE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3939 rettv->vval.v_string = vim_strsave(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3940 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3941 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
3942
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3943 convert_setup(&vimconv, NULL, NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3944 vim_free(from);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3945 vim_free(to);
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3948 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3949 * "indent()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3950 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3951 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3952 f_indent(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3953 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3954 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3955
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
3956 lnum = tv_get_lnum(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3957 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
3958 rettv->vval.v_number = get_indent_lnum(lnum);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3959 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3960 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3961 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3962
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3963 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3964 * "index()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3965 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3966 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3967 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
3968 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3969 list_T *l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3970 listitem_T *item;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3971 blob_T *b;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3972 long idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3973 int ic = FALSE;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3974 int error = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3975
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3976 rettv->vval.v_number = -1;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3977 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
3978 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3979 typval_T tv;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3980 int start = 0;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3981
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3982 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
3983 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3984 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
3985 if (error)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3986 return;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3987 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3988 b = argvars[0].vval.v_blob;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3989 if (b == NULL)
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3990 return;
15468
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3991 if (start < 0)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3992 {
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3993 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
3994 if (start < 0)
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3995 start = 0;
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3996 }
1550cc188ff6 patch 8.1.0742: not all Blob operations are tested
Bram Moolenaar <Bram@vim.org>
parents: 15456
diff changeset
3997
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
3998 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
3999 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4000 tv.v_type = VAR_NUMBER;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4001 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
4002 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
4003 {
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4004 rettv->vval.v_number = idx;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4005 return;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4006 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4007 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4008 return;
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4009 }
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4010 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
4011 {
15571
4af72c724093 patch 8.1.0793: incorrect error messages for functions that take a Blob
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
4012 emsg(_(e_listblobreq));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4013 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4014 }
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4015
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4016 l = argvars[0].vval.v_list;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4017 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4018 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4019 item = l->lv_first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4020 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4021 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4022 /* 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
4023 * 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
4024 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
4025 idx = l->lv_idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4026 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
4027 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
4028 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4029 item = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4030 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4031
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4032 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
4033 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
4034 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4035 rettv->vval.v_number = idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4036 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4037 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4038 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4039 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4040
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4041 static int inputsecret_flag = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4042
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4043 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4044 * "input()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4045 * Also handles inputsecret() when inputsecret is set.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4046 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4047 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4048 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
4049 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4050 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
4051 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4052
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4053 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4054 * "inputdialog()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4055 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4056 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4057 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
4058 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4059 #if defined(FEAT_GUI_TEXTDIALOG)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4060 /* 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
4061 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
4062 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4063 char_u *message;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4064 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4065 char_u *defstr = (char_u *)"";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4066
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4067 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
4068 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
4069 && (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
4070 vim_strncpy(IObuff, defstr, IOSIZE - 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4071 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4072 IObuff[0] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4073 if (message != NULL && defstr != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4074 && do_dialog(VIM_QUESTION, NULL, message,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4075 (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
4076 rettv->vval.v_string = vim_strsave(IObuff);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4077 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4078 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4079 if (message != NULL && defstr != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4080 && argvars[1].v_type != VAR_UNKNOWN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4081 && argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4082 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
4083 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
4084 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4085 rettv->vval.v_string = NULL;
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 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4088 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4089 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4090 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4091 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
4092 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4093
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4094 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4095 * "inputlist()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4096 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4097 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4098 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
4099 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4100 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4101 int selected;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4102 int mouse_used;
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 #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
4105 /* 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
4106 * 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
4107 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
4108 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4109 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4110 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
4111 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
4112 semsg(_(e_listarg), "inputlist()");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4113 return;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4116 msg_start();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4117 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
4118 lines_left = Rows; /* avoid more prompt */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4119 msg_scroll = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4120 msg_clr_eos();
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 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
4123 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
4124 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
4125 msg_putchar('\n');
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 /* Ask for choice. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4129 selected = prompt_for_number(&mouse_used);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4130 if (mouse_used)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4131 selected -= lines_left;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4132
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4133 rettv->vval.v_number = selected;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4136 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
4137
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4138 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4139 * "inputrestore()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4140 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4141 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4142 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
4143 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4144 if (ga_userinput.ga_len > 0)
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 --ga_userinput.ga_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4147 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
4148 + ga_userinput.ga_len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4149 /* default return is zero == OK */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4150 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4151 else if (p_verbose > 1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4152 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15510
diff changeset
4153 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
4154 rettv->vval.v_number = 1; /* Failed */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4155 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4156 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4157
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 * "inputsave()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4160 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4161 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4162 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
4163 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4164 /* 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
4165 if (ga_grow(&ga_userinput, 1) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4166 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4167 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
4168 + ga_userinput.ga_len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4169 ++ga_userinput.ga_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4170 /* default return is zero == OK */
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 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4173 rettv->vval.v_number = 1; /* Failed */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4174 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4175
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 * "inputsecret()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4180 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
4181 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4182 ++cmdline_star;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4183 ++inputsecret_flag;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4184 f_input(argvars, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4185 --cmdline_star;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4186 --inputsecret_flag;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4187 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4188
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4189 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4190 * "invert(expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4191 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4192 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4193 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
4194 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4195 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
4196 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4197
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4198 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4199 * 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
4200 * 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
4201 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4202 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4203 tv_islocked(typval_T *tv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4204 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4205 return (tv->v_lock & VAR_LOCKED)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4206 || (tv->v_type == VAR_LIST
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4207 && tv->vval.v_list != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4208 && (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
4209 || (tv->v_type == VAR_DICT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4210 && tv->vval.v_dict != NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4211 && (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
4212 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4213
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4214 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4215 * "islocked()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4216 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4217 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4218 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
4219 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4220 lval_T lv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4221 char_u *end;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4222 dictitem_T *di;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4223
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4224 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
4225 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
4226 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
4227 if (end != NULL && lv.ll_name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4228 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4229 if (*end != NUL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
4230 emsg(_(e_trailing));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4231 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4232 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4233 if (lv.ll_tv == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4234 {
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
4235 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
4236 if (di != NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4237 {
10889
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
4238 /* 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
4239 * 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
4240 * 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
4241 * 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
4242 */
5780bd3a5a7e patch 8.0.0334: can't access b:changedtick from a dict reference
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
4243 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
4244 || tv_islocked(&di->di_tv));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4245 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4246 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4247 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
4248 emsg(_("E786: Range not allowed"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4249 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
4250 semsg(_(e_dictkey), lv.ll_newkey);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4251 else if (lv.ll_list != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4252 /* List item. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4253 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
4254 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4255 /* Dictionary item. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4256 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
4257 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4258 }
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 clear_lval(&lv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4261 }
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 #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
4264 /*
16213
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4265 * "isinf()" function
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4266 */
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4267 static void
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4268 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
4269 {
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4270 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
4271 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
4272 }
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4273
2c33b119ba92 patch 8.1.1111: it is not easy to check for infinity
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
4274 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4275 * "isnan()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4276 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4277 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4278 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
4279 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4280 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
4281 && isnan(argvars[0].vval.v_float);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4282 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4283 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4284
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4285 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4286 * "last_buffer_nr()" function.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4287 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4288 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4289 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
4290 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4291 int n = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4292 buf_T *buf;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4293
9649
fd9727ae3c49 commit https://github.com/vim/vim/commit/2932359000b2f918d5fade79ea4d124d5943cd07
Christian Brabandt <cb@256bit.org>
parents: 9636
diff changeset
4294 FOR_ALL_BUFFERS(buf)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4295 if (n < buf->b_fnum)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4296 n = buf->b_fnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4297
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4298 rettv->vval.v_number = n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4299 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4300
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4301 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4302 * "len()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4303 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4304 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4305 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
4306 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4307 switch (argvars[0].v_type)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4308 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4309 case VAR_STRING:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4310 case VAR_NUMBER:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4311 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
4312 tv_get_string(&argvars[0]));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4313 break;
15454
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4314 case VAR_BLOB:
1d2b5c016f17 patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents: 15444
diff changeset
4315 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
4316 break;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4317 case VAR_LIST:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4318 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
4319 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4320 case VAR_DICT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4321 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
4322 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4323 case VAR_UNKNOWN:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4324 case VAR_SPECIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4325 case VAR_FLOAT:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4326 case VAR_FUNC:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4327 case VAR_PARTIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4328 case VAR_JOB:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4329 case VAR_CHANNEL:
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
4330 emsg(_("E701: Invalid type for len()"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4331 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4332 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4333 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4334
10620
2198b53b9ffe patch 8.0.0199: compiler warnings for libcall
Christian Brabandt <cb@256bit.org>
parents: 10567
diff changeset
4335 static void
2198b53b9ffe patch 8.0.0199: compiler warnings for libcall
Christian Brabandt <cb@256bit.org>
parents: 10567
diff changeset
4336 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
4337 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4338 #ifdef FEAT_LIBCALL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4339 char_u *string_in;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4340 char_u **string_result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4341 int nr_result;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4342 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4343
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4344 rettv->v_type = type;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4345 if (type != VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4346 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4347
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4348 if (check_restricted() || check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4349 return;
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 #ifdef FEAT_LIBCALL
10226
7a4fb555c83a commit https://github.com/vim/vim/commit/9af418427652562384744648d7d173a4bfebba95
Christian Brabandt <cb@256bit.org>
parents: 10207
diff changeset
4352 /* 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
4353 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
4354 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4355 string_in = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4356 if (argvars[2].v_type == VAR_STRING)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4357 string_in = argvars[2].vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4358 if (type == VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4359 string_result = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4360 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4361 string_result = &rettv->vval.v_string;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4362 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
4363 argvars[1].vval.v_string,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4364 string_in,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4365 argvars[2].vval.v_number,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4366 string_result,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4367 &nr_result) == OK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4368 && type == VAR_NUMBER)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4369 rettv->vval.v_number = nr_result;
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4372 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4373
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 * "libcall()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4376 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4377 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4378 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
4379 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4380 libcall_common(argvars, rettv, VAR_STRING);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4381 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4382
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4383 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4384 * "libcallnr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4385 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4386 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4387 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
4388 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4389 libcall_common(argvars, rettv, VAR_NUMBER);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4390 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4391
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4392 /*
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4393 * "line(string, [winid])" function
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4394 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4395 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4396 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
4397 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4398 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
4399 pos_T *fp = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4400 int fnum;
17942
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4401 int id;
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4402 tabpage_T *tp;
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4403 win_T *wp;
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4404 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
4405 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
4406
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4407 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
4408 {
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4409 // 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
4410 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
4411 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
4412 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
4413 {
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4414 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
4415 == OK)
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4416 {
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4417 check_cursor();
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4418 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
4419 }
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4420 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
4421 }
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4422 }
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4423 else
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4424 // use current window
664cc72f50c5 patch 8.1.1967: line() only works for the current window
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
4425 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
4426
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4427 if (fp != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4428 lnum = fp->lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4429 rettv->vval.v_number = lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4430 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4431
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 * "line2byte(lnum)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4434 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4435 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4436 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
4437 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4438 #ifndef FEAT_BYTEOFF
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4439 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4440 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4441 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4442
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4443 lnum = tv_get_lnum(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4444 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
4445 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4446 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4447 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
4448 if (rettv->vval.v_number >= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4449 ++rettv->vval.v_number;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4450 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4451 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4452
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4453 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4454 * "lispindent(lnum)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4455 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4456 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4457 f_lispindent(typval_T *argvars UNUSED, typval_T *rettv)
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 #ifdef FEAT_LISP
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4460 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4461 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4462
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4463 pos = curwin->w_cursor;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4464 lnum = tv_get_lnum(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4465 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
4466 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4467 curwin->w_cursor.lnum = lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4468 rettv->vval.v_number = get_lisp_indent();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4469 curwin->w_cursor = pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4470 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4471 else
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 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4474 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4477 * "localtime()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4478 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4479 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4480 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
4481 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4482 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
4483 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4484
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4485 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4486 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4487 * "log()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4488 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4489 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4490 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
4491 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4492 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4493
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4494 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4495 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4496 rettv->vval.v_float = log(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4497 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4498 rettv->vval.v_float = 0.0;
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 * "log10()" 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_log10(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 float_T f = 0.0;
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 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4510 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4511 rettv->vval.v_float = log10(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4512 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4513 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4514 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4515 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4516
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4517 #ifdef FEAT_LUA
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4518 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4519 * "luaeval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4520 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4521 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4522 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
4523 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4524 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4525 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4526
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
4527 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
4528 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
4529
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4530 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
4531 do_luaeval(str, argvars + 1, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4532 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4533 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4534
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4535 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4536 * "maparg()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4537 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4538 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4539 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
4540 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4541 get_maparg(argvars, rettv, TRUE);
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4544 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4545 * "mapcheck()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4546 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4547 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4548 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
4549 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4550 get_maparg(argvars, rettv, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4551 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4552
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4553 typedef enum
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4554 {
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4555 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
4556 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
4557 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
4558 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
4559 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
4560 } matchtype_T;
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4561
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4562 static void
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4563 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
4564 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4565 char_u *str = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4566 long len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4567 char_u *expr = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4568 char_u *pat;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4569 regmatch_T regmatch;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4570 char_u patbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4571 char_u strbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4572 char_u *save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4573 long start = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4574 long nth = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4575 colnr_T startcol = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4576 int match = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4577 list_T *l = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4578 listitem_T *li = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4579 long idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4580 char_u *tofree = NULL;
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 /* 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
4583 save_cpo = p_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4584 p_cpo = (char_u *)"";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4585
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4586 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
4587 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
4588 {
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4589 /* 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
4590 * 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
4591 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4592 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
4593 if (type == MATCH_POS
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4594 && (list_append_string(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4595 (char_u *)"", 0) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4596 || list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4597 (varnumber_T)-1) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4598 || list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4599 (varnumber_T)-1) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4600 || list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4601 (varnumber_T)-1) == FAIL))
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 list_free(rettv->vval.v_list);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4604 rettv->vval.v_list = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4605 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4606 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4607 }
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4608 else if (type == MATCH_STR)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4609 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4610 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4611 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4612 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4613
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4614 if (argvars[0].v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4615 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4616 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
4617 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4618 li = l->lv_first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4619 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4620 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4621 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4622 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
4623 len = (long)STRLEN(str);
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
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4626 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
4627 if (pat == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4628 goto theend;
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 if (argvars[2].v_type != VAR_UNKNOWN)
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 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4633
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4634 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
4635 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4636 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4637 if (l != NULL)
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 li = list_find(l, start);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4640 if (li == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4641 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4642 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
4643 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4644 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4645 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4646 if (start < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4647 start = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4648 if (start > len)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4649 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4650 /* 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
4651 * 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
4652 * or "\<". */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4653 if (argvars[3].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4654 startcol = start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4655 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4656 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4657 str += start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4658 len -= start;
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 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4661
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4662 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
4663 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
4664 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4665 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4666 }
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 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
4669 if (regmatch.regprog != NULL)
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 regmatch.rm_ic = p_ic;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4672
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4673 for (;;)
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 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4676 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4677 if (li == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4678 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4679 match = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4680 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4681 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4682 vim_free(tofree);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4683 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
4684 if (str == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4685 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4686 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4687
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4688 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
4689
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4690 if (match && --nth <= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4691 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4692 if (l == NULL && !match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4693 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4694
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4695 /* Advance to just after the match. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4696 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4697 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4698 li = li->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4699 ++idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4700 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4701 else
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 startcol = (colnr_T)(regmatch.startp[0]
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4704 + (*mb_ptr2len)(regmatch.startp[0]) - str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4705 if (startcol > (colnr_T)len
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4706 || str + startcol <= regmatch.startp[0])
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4707 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4708 match = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4709 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4710 }
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 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4713
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4714 if (match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4715 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4716 if (type == MATCH_POS)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4717 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4718 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
4719 listitem_T *li2 = li1->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4720 listitem_T *li3 = li2->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4721 listitem_T *li4 = li3->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4722
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4723 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
4724 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
4725 (int)(regmatch.endp[0] - regmatch.startp[0]));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4726 li3->li_tv.vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4727 (varnumber_T)(regmatch.startp[0] - expr);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4728 li4->li_tv.vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4729 (varnumber_T)(regmatch.endp[0] - expr);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4730 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4731 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
4732 }
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4733 else if (type == MATCH_LIST)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4734 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4735 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4736
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4737 /* return list with matched string and submatches */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4738 for (i = 0; i < NSUBEXP; ++i)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4739 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4740 if (regmatch.endp[i] == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4741 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4742 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
4743 (char_u *)"", 0) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4744 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4745 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4746 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
4747 regmatch.startp[i],
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4748 (int)(regmatch.endp[i] - regmatch.startp[i]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4749 == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4750 break;
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 }
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4753 else if (type == MATCH_STR)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4754 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4755 /* return matched string */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4756 if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4757 copy_tv(&li->li_tv, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4758 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4759 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
4760 (int)(regmatch.endp[0] - regmatch.startp[0]));
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 else if (l != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4763 rettv->vval.v_number = idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4764 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4765 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4766 if (type != MATCH_END)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4767 rettv->vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4768 (varnumber_T)(regmatch.startp[0] - str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4769 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4770 rettv->vval.v_number =
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4771 (varnumber_T)(regmatch.endp[0] - str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4772 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
4773 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4774 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4775 vim_regfree(regmatch.regprog);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4776 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4777
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4778 theend:
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4779 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
4780 /* 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
4781 listitem_remove(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4782 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
4783 vim_free(tofree);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4784 p_cpo = save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4785 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4786
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 * "match()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4789 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4790 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4791 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
4792 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4793 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
4794 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4797 * "matchend()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4798 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4799 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4800 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
4801 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4802 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
4803 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4804
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4805 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4806 * "matchlist()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4807 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4808 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4809 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
4810 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4811 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
4812 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4813
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4814 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4815 * "matchstr()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4818 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
4819 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4820 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
4821 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4822
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4823 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4824 * "matchstrpos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4825 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4826 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4827 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
4828 {
12248
f9de19f981a4 patch 8.0.1004: matchstrpos() without a match returns too many items
Christian Brabandt <cb@256bit.org>
parents: 12144
diff changeset
4829 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
4830 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4831
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4832 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4833 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
4834 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4835 varnumber_T n = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4836 varnumber_T i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4837 int error = FALSE;
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 if (argvars[0].v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4840 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4841 list_T *l;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4842 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4843
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4844 l = argvars[0].vval.v_list;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4845 if (l != NULL)
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 li = l->lv_first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4848 if (li != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4849 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4850 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
4851 for (;;)
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 li = li->li_next;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4854 if (li == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4855 break;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4856 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
4857 if (domax ? i > n : i < n)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4858 n = i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4859 }
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 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
4864 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4865 dict_T *d;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4866 int first = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4867 hashitem_T *hi;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4868 int todo;
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 d = argvars[0].vval.v_dict;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4871 if (d != NULL)
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 todo = (int)d->dv_hashtab.ht_used;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4874 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
4875 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4876 if (!HASHITEM_EMPTY(hi))
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 --todo;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
4879 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
4880 if (first)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4881 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4882 n = i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4883 first = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4884 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4885 else if (domax ? i > n : i < n)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4886 n = i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4887 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4888 }
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 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4891 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
4892 semsg(_(e_listdictarg), domax ? "max()" : "min()");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4893 rettv->vval.v_number = error ? 0 : n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4894 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4895
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4896 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4897 * "max()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4900 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
4901 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4902 max_min(argvars, rettv, TRUE);
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4905 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4906 * "min()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4907 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4908 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4909 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
4910 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4911 max_min(argvars, rettv, FALSE);
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4914 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4915 * "mode()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4916 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4917 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4918 f_mode(typval_T *argvars, typval_T *rettv)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4919 {
14422
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14407
diff changeset
4920 char_u buf[4];
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14407
diff changeset
4921
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14407
diff changeset
4922 vim_memset(buf, 0, sizeof(buf));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4923
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4924 if (time_for_testing == 93784)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4925 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4926 /* Testing the two-character code. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4927 buf[0] = 'x';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4928 buf[1] = '!';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4929 }
12112
6afc7339c2ad patch 8.0.0936: mode() returns wrong value for a terminal window
Christian Brabandt <cb@256bit.org>
parents: 12102
diff changeset
4930 #ifdef FEAT_TERMINAL
6afc7339c2ad patch 8.0.0936: mode() returns wrong value for a terminal window
Christian Brabandt <cb@256bit.org>
parents: 12102
diff changeset
4931 else if (term_use_loop())
6afc7339c2ad patch 8.0.0936: mode() returns wrong value for a terminal window
Christian Brabandt <cb@256bit.org>
parents: 12102
diff changeset
4932 buf[0] = 't';
6afc7339c2ad patch 8.0.0936: mode() returns wrong value for a terminal window
Christian Brabandt <cb@256bit.org>
parents: 12102
diff changeset
4933 #endif
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4934 else if (VIsual_active)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4935 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4936 if (VIsual_select)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4937 buf[0] = VIsual_mode + 's' - 'v';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4938 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4939 buf[0] = VIsual_mode;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4940 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4941 else if (State == HITRETURN || State == ASKMORE || State == SETWSIZE
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4942 || State == CONFIRM)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4943 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4944 buf[0] = 'r';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4945 if (State == ASKMORE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4946 buf[1] = 'm';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4947 else if (State == CONFIRM)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4948 buf[1] = '?';
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 else if (State == EXTERNCMD)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4951 buf[0] = '!';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4952 else if (State & INSERT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4953 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4954 if (State & VREPLACE_FLAG)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4955 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4956 buf[0] = 'R';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4957 buf[1] = 'v';
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 else
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4960 {
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4961 if (State & REPLACE_FLAG)
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4962 buf[0] = 'R';
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4963 else
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4964 buf[0] = 'i';
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4965 if (ins_compl_active())
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4966 buf[1] = 'c';
13212
a80490493c6b patch 8.0.1480: patch missing change
Christian Brabandt <cb@256bit.org>
parents: 13123
diff changeset
4967 else if (ctrl_x_mode_not_defined_yet())
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4968 buf[1] = 'x';
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4969 }
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4970 }
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4971 else if ((State & CMDLINE) || exmode_active)
9571
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 buf[0] = 'c';
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4974 if (exmode_active == EXMODE_VIM)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4975 buf[1] = 'v';
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4976 else if (exmode_active == EXMODE_NORMAL)
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10749
diff changeset
4977 buf[1] = 'e';
9571
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 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4980 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4981 buf[0] = 'n';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4982 if (finish_op)
15279
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 15271
diff changeset
4983 {
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4984 buf[1] = 'o';
15279
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 15271
diff changeset
4985 // to be able to detect force-linewise/blockwise/characterwise operations
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 15271
diff changeset
4986 buf[2] = motion_force;
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 15271
diff changeset
4987 }
14422
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14407
diff changeset
4988 else if (restart_edit == 'I' || restart_edit == 'R'
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14407
diff changeset
4989 || restart_edit == 'V')
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14407
diff changeset
4990 {
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14407
diff changeset
4991 buf[1] = 'i';
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14407
diff changeset
4992 buf[2] = restart_edit;
06316dbd66bc patch 8.1.0225: mode() does not indicate using CTRL-O from Insert mode
Christian Brabandt <cb@256bit.org>
parents: 14407
diff changeset
4993 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4994 }
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 /* Clear out the minor mode when the argument is not a non-zero number or
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4997 * non-empty string. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4998 if (!non_zero_arg(&argvars[0]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4999 buf[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5000
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5001 rettv->vval.v_string = vim_strsave(buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5002 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5003 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5004
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5005 #if defined(FEAT_MZSCHEME) || defined(PROTO)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5006 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5007 * "mzeval()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5010 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
5011 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5012 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5013 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5014
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5015 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
5016 return;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5017 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
5018 do_mzeval(str, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5019 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5020
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5021 void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5022 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
5023 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5024 typval_T argvars[3];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5025
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5026 argvars[0].v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5027 argvars[0].vval.v_string = name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5028 copy_tv(args, &argvars[1]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5029 argvars[2].v_type = VAR_UNKNOWN;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5030 f_call(argvars, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5031 clear_tv(&argvars[1]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5032 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5033 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5034
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5035 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5036 * "nextnonblank()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5037 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5038 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5039 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
5040 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5041 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5042
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5043 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
5044 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5045 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
5046 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5047 lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5048 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5049 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5050 if (*skipwhite(ml_get(lnum)) != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5051 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5052 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5053 rettv->vval.v_number = lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5054 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5055
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5056 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5057 * "nr2char()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5058 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5059 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5060 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
5061 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5062 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5063
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5064 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5065 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5066 int utf8 = 0;
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 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
5069 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
5070 if (utf8)
15967
ddd82b1c9e9d patch 8.1.0989: various small code ugliness
Bram Moolenaar <Bram@vim.org>
parents: 15955
diff changeset
5071 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
5072 else
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5073 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
5074 }
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5075 else
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5076 {
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5077 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
5078 buf[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5079 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5080 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5081 rettv->vval.v_string = vim_strsave(buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5082 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5083
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5084 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5085 * "or(expr, expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5086 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5087 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5088 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
5089 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5090 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
5091 | 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
5092 }
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 #ifdef FEAT_PERL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5095 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5096 * "perleval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5097 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5098 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5099 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
5100 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5101 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5102 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5103
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5104 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
5105 do_perleval(str, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5106 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5107 #endif
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 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5110 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5111 * "pow()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5112 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5113 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5114 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
5115 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5116 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
5117
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5118 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5119 if (get_float_arg(argvars, &fx) == OK
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5120 && get_float_arg(&argvars[1], &fy) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5121 rettv->vval.v_float = pow(fx, fy);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5122 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5123 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5124 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5125 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5126
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5127 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5128 * "prevnonblank()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5129 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5130 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5131 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
5132 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5133 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5134
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5135 lnum = tv_get_lnum(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5136 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
5137 lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5138 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5139 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
5140 --lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5141 rettv->vval.v_number = lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5142 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5143
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5144 /* This dummy va_list is here because:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5145 * - 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
5146 * - 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
5147 * - 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
5148 static va_list ap;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5149
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5150 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5151 * "printf()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5152 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5153 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5154 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
5155 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5156 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5157 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5158 char_u *s;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5159 int saved_did_emsg = did_emsg;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5160 char *fmt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5161
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5162 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5163 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5164
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5165 /* 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
5166 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
5167 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
5168 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
5169 if (!did_emsg)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5170 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5171 s = alloc(len + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5172 if (s != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5173 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5174 rettv->vval.v_string = s;
11653
67cf0d45b006 patch 8.0.0709: libvterm cannot use vsnprintf()
Christian Brabandt <cb@256bit.org>
parents: 11621
diff changeset
5175 (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
5176 ap, argvars + 1);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5177 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5178 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5179 did_emsg |= saved_did_emsg;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5180 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5181
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5182 /*
17756
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5183 * "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
5184 */
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5185 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
5186 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
5187 {
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5188 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
5189 return;
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5190 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
5191 }
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5192
a7afcea6f40a patch 8.1.1875: cannot get size and position of the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17744
diff changeset
5193 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5194 * "pumvisible()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5195 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5196 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5197 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
5198 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5199 if (pum_visible())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5200 rettv->vval.v_number = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5201 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5202
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5203 #ifdef FEAT_PYTHON3
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5204 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5205 * "py3eval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5206 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5207 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5208 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
5209 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5210 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5211 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5212
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5213 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
5214 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5215
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5216 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
5217 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
5218
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5219 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
5220 do_py3eval(str, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5221 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5222 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5223
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5224 #ifdef FEAT_PYTHON
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 * "pyeval()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5227 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5228 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5229 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
5230 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5231 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5232 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5233
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5234 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
5235 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5236
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5237 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
5238 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
5239
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5240 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
5241 do_pyeval(str, rettv);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5242 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5243 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5244
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5245 #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
5246 /*
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5247 * "pyxeval()" function
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5248 */
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5249 static void
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5250 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
5251 {
15748
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5252 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
5253 return;
93b78c4a7cd5 patch 8.1.0881: can execute shell commands in rvim through interfaces
Bram Moolenaar <Bram@vim.org>
parents: 15725
diff changeset
5254
10722
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5255 # 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
5256 init_pyxversion();
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5257 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
5258 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
5259 else
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5260 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
5261 # 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
5262 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
5263 # 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
5264 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
5265 # endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5266 }
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5267 #endif
7598ce51bf2a patch 8.0.0251: not easy to select Python 2 or 3
Christian Brabandt <cb@256bit.org>
parents: 10706
diff changeset
5268
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5269 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5270 * "range()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5271 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5272 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5273 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
5274 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5275 varnumber_T start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5276 varnumber_T end;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5277 varnumber_T stride = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5278 varnumber_T i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5279 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5280
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5281 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
5282 if (argvars[1].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5283 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5284 end = start - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5285 start = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5286 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5287 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5288 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5289 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
5290 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
5291 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
5292 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5293
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5294 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5295 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5296 if (stride == 0)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5297 emsg(_("E726: Stride is zero"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5298 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
5299 emsg(_("E727: Start past end"));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5300 else
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 if (rettv_list_alloc(rettv) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5303 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
5304 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
5305 (varnumber_T)i) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5306 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5307 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5308 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5309
14004
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5310 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
5311 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
5312 {
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5313 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
5314
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5315 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
5316 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
5317 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
5318 }
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5319
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5320 /*
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5321 * "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
5322 */
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5323 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
5324 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
5325 {
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5326 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
5327 }
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5328
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5329 /*
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5330 * "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
5331 */
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5332 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
5333 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
5334 {
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5335 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
5336 }
e124262d435e patch 8.1.0020: cannot tell whether a register is executing or recording
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
5337
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5338 #if defined(FEAT_RELTIME)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5339 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5340 * Convert a List to proftime_T.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5341 * Return FAIL when there is something wrong.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5342 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5343 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5344 list2proftime(typval_T *arg, proftime_T *tm)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5345 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5346 long n1, n2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5347 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5348
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5349 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
5350 || arg->vval.v_list->lv_len != 2)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5351 return FAIL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5352 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
5353 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
5354 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5355 tm->HighPart = n1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5356 tm->LowPart = n2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5357 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5358 tm->tv_sec = n1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5359 tm->tv_usec = n2;
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 return error ? FAIL : OK;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5362 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5363 #endif /* FEAT_RELTIME */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5364
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5365 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5366 * "reltime()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5367 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5368 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5369 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
5370 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5371 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5372 proftime_T res;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5373 proftime_T start;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5374
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5375 if (argvars[0].v_type == VAR_UNKNOWN)
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 /* No arguments: get current time. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5378 profile_start(&res);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5379 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5380 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
5381 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5382 if (list2proftime(&argvars[0], &res) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5383 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5384 profile_end(&res);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5385 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5386 else
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 /* Two arguments: compute the difference. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5389 if (list2proftime(&argvars[0], &start) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5390 || list2proftime(&argvars[1], &res) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5391 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5392 profile_sub(&res, &start);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5393 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5394
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5395 if (rettv_list_alloc(rettv) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5396 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5397 long n1, n2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5398
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5399 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5400 n1 = res.HighPart;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5401 n2 = res.LowPart;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5402 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5403 n1 = res.tv_sec;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5404 n2 = res.tv_usec;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5405 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5406 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
5407 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
5408 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5409 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5410 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5411
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5412 #ifdef FEAT_FLOAT
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 * "reltimefloat()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5417 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
5418 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5419 # ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5420 proftime_T tm;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5421 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5422
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5423 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5424 rettv->vval.v_float = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5425 # ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5426 if (list2proftime(&argvars[0], &tm) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5427 rettv->vval.v_float = profile_float(&tm);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5428 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5429 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5430 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5431
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 * "reltimestr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5434 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5435 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5436 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
5437 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5438 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5439 proftime_T tm;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5440 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5441
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5442 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5443 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5444 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5445 if (list2proftime(&argvars[0], &tm) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5446 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
5447 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5448 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5449
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5450 #if defined(FEAT_CLIENTSERVER) && defined(FEAT_X11)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5451 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5452 make_connection(void)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5453 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5454 if (X_DISPLAY == NULL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5455 # ifdef FEAT_GUI
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5456 && !gui.in_use
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5457 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5458 )
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5459 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5460 x_force_connect = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5461 setup_term_clip();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5462 x_force_connect = FALSE;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5466 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5467 check_connection(void)
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 make_connection();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5470 if (X_DISPLAY == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5471 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5472 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
5473 return FAIL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5474 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5475 return OK;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5476 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5477 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5478
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5479 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5480 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5481 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
5482 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5483 char_u *server_name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5484 char_u *keys;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5485 char_u *r = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5486 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
5487 int timeout = 0;
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5488 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5489 HWND w;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5490 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5491 Window w;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5492 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5493
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5494 if (check_restricted() || check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5495 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5496
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5497 # ifdef FEAT_X11
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5498 if (check_connection() == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5499 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5500 # 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
5501 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
5502 && 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
5503 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
5504
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5505 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
5506 if (server_name == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5507 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
5508 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
5509 # 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
5510 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
5511 # 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
5512 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
5513 0, TRUE) < 0)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5514 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5515 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5516 if (r != NULL)
12399
de1ae9d8ef57 patch 8.0.1079: memory leak when remote_foreground() fails
Christian Brabandt <cb@256bit.org>
parents: 12389
diff changeset
5517 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5518 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
5519 vim_free(r);
de1ae9d8ef57 patch 8.0.1079: memory leak when remote_foreground() fails
Christian Brabandt <cb@256bit.org>
parents: 12389
diff changeset
5520 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5521 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5522 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
5523 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5524 }
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 rettv->vval.v_string = r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5527
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5528 if (argvars[2].v_type != VAR_UNKNOWN)
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 dictitem_T v;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5531 char_u str[30];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5532 char_u *idvar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5533
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5534 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
5535 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
5536 {
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5537 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
5538 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
5539 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
5540 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
5541 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
5542 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5543 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5544 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5545 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5546
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5547 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5548 * "remote_expr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5549 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5550 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5551 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
5552 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5553 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5554 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5555 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5556 remote_common(argvars, rettv, TRUE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5557 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5558 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5559
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5560 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5561 * "remote_foreground()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5562 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5563 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5564 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
5565 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5566 #ifdef FEAT_CLIENTSERVER
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5567 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5568 /* 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
5569 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5570 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
5571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5572 if (server_name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5573 serverForeground(server_name);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5574 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5575 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5576 /* Send a foreground() expression to the server. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5577 argvars[1].v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5578 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
5579 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
5580 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
5581 rettv->vval.v_string = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5582 remote_common(argvars, rettv, TRUE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5583 vim_free(argvars[1].vval.v_string);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5584 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5585 #endif
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5588 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5589 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
5590 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5591 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5592 dictitem_T v;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5593 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
5594 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5595 long_u n = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5596 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5597 char_u *serverid;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5598
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5599 if (check_restricted() || check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5600 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5601 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5602 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5603 }
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5604 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
5605 if (serverid == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5606 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5607 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5608 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5609 }
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5610 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5611 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
5612 if (n == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5613 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5614 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5615 {
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5616 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
5617 rettv->vval.v_number = (s != NULL);
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 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5620 if (check_connection() == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5621 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5622
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5623 rettv->vval.v_number = serverPeekReply(X_DISPLAY,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5624 serverStrToWin(serverid), &s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5625 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5626
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5627 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
5628 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5629 char_u *retvar;
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 v.di_tv.v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5632 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
5633 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
5634 if (retvar != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5635 set_var(retvar, &v.di_tv, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5636 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
5637 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5638 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5639 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5640 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5641 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5642
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5643 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5644 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
5645 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5646 char_u *r = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5647
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5648 #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
5649 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
5650
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5651 if (serverid != NULL && !check_restricted() && !check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5652 {
11211
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5653 int timeout = 0;
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5654 # 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
5655 /* 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
5656 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
5657 # 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
5658
71311d899b42 patch 8.0.0492: a failing client-server request can make Vim hang
Christian Brabandt <cb@256bit.org>
parents: 11181
diff changeset
5659 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
5660 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
5661
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
5662 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5663 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
5664 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
5665 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
5666 if (r == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5667 # 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
5668 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
5669 || 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
5670 &r, FALSE, timeout) < 0)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5671 # endif
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5672 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
5673 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5674 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5675 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5676 rettv->vval.v_string = r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5677 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5680 * "remote_send()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5681 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5682 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5683 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
5684 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5685 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5686 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5687 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5688 remote_common(argvars, rettv, FALSE);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5689 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5690 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5691
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5692 /*
11177
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5693 * "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
5694 */
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5695 static void
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5696 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
5697 {
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5698 #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
5699 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
5700
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5701 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
5702 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
5703 if (serverName != NULL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5704 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
5705 else
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5706 {
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5707 # 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
5708 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
5709 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
5710 # else
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5711 serverSetName(server);
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5712 # endif
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5713 }
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5714 #else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5715 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
5716 #endif
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5717 }
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5718
76fb679a310e patch 8.0.0475: not enough testing for the client-server feature
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
5719 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5720 * "rename({from}, {to})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5721 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5722 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5723 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
5724 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5725 char_u buf[NUMBUFLEN];
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 if (check_restricted() || check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5728 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5729 else
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5730 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
5731 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
5732 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5733
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 * "repeat()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5736 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5737 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5738 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
5739 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5740 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5741 int n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5742 int slen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5743 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5744 char_u *r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5745 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5746
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5747 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
5748 if (argvars[0].v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5749 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5750 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
5751 while (n-- > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5752 if (list_extend(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5753 argvars[0].vval.v_list, NULL) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5754 break;
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 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5757 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5758 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5759 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5760 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5761
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5762 slen = (int)STRLEN(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5763 len = slen * n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5764 if (len <= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5765 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5766
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5767 r = alloc(len + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5768 if (r != NULL)
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 for (i = 0; i < n; i++)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5771 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
5772 r[len] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5773 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5774
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5775 rettv->vval.v_string = r;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5779 #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
5780 #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
5781 #define SP_RETCOUNT 0x04 /* return matchcount */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5782 #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
5783 #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
5784 #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
5785 #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
5786 #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
5787
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5788 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5789 * Get flags for a search function.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5790 * Possibly sets "p_ws".
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5791 * 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
5792 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5793 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5794 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
5795 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5796 int dir = FORWARD;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5797 char_u *flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5798 char_u nbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5799 int mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5800
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5801 if (varp->v_type != VAR_UNKNOWN)
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 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
5804 if (flags == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5805 return 0; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5806 while (*flags != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5807 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5808 switch (*flags)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5809 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5810 case 'b': dir = BACKWARD; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5811 case 'w': p_ws = TRUE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5812 case 'W': p_ws = FALSE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5813 default: mask = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5814 if (flagsp != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5815 switch (*flags)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5816 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5817 case 'c': mask = SP_START; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5818 case 'e': mask = SP_END; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5819 case 'm': mask = SP_RETCOUNT; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5820 case 'n': mask = SP_NOMOVE; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5821 case 'p': mask = SP_SUBPAT; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5822 case 'r': mask = SP_REPEAT; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5823 case 's': mask = SP_SETPCMARK; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5824 case 'z': mask = SP_COLUMN; break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5825 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5826 if (mask == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5827 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5828 semsg(_(e_invarg2), flags);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5829 dir = 0;
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 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5832 *flagsp |= mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5833 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5834 if (dir == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5835 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5836 ++flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5837 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5838 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5839 return dir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5840 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5843 * Shared by search() and searchpos() functions.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5844 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5845 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5846 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
5847 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5848 int flags;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5849 char_u *pat;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5850 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5851 pos_T save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5852 int save_p_ws = p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5853 int dir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5854 int retval = 0; /* default: FAIL */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5855 long lnum_stop = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5856 proftime_T tm;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5857 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5858 long time_limit = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5859 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5860 int options = SEARCH_KEEP;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5861 int subpatnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5862
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5863 pat = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5864 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
5865 if (dir == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5866 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5867 flags = *flagsp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5868 if (flags & SP_START)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5869 options |= SEARCH_START;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5870 if (flags & SP_END)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5871 options |= SEARCH_END;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5872 if (flags & SP_COLUMN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5873 options |= SEARCH_COL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5874
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5875 /* 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
5876 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
5877 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5878 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
5879 if (lnum_stop < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5880 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5881 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5882 if (argvars[3].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5883 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5884 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
5885 if (time_limit < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5886 goto theend;
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 #endif
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 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5892 /* 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
5893 profile_setlimit(time_limit, &tm);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5894 #endif
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5897 * 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
5898 * 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
5899 * 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
5900 * 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
5901 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5902 if (((flags & (SP_REPEAT | SP_RETCOUNT)) != 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5903 || ((flags & SP_NOMOVE) && (flags & SP_SETPCMARK)))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5904 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
5905 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
5906 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5907 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5908
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5909 pos = save_cursor = curwin->w_cursor;
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
5910 subpatnum = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L,
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11519
diff changeset
5911 options, RE_SEARCH, (linenr_T)lnum_stop, &tm, NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5912 if (subpatnum != FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5913 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5914 if (flags & SP_SUBPAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5915 retval = subpatnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5916 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5917 retval = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5918 if (flags & SP_SETPCMARK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5919 setpcmark();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5920 curwin->w_cursor = pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5921 if (match_pos != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5922 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5923 /* Store the match cursor position */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5924 match_pos->lnum = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5925 match_pos->col = pos.col + 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5926 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5927 /* "/$" 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
5928 * correct that here */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5929 check_cursor();
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5932 /* 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
5933 if (flags & SP_NOMOVE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5934 curwin->w_cursor = save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5935 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5936 curwin->w_set_curswant = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5937 theend:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5938 p_ws = save_p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5939
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5940 return retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5941 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5942
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5943 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5944
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5945 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5946 * 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
5947 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5948 float_T
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5949 vim_round(float_T f)
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 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
5952 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5953
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5954 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5955 * "round({float})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5956 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5957 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5958 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
5959 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5960 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5961
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5962 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5963 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5964 rettv->vval.v_float = vim_round(f);
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 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5967 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5968 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5969
16103
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5970 #ifdef FEAT_RUBY
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5971 /*
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5972 * "rubyeval()" function
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5973 */
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5974 static void
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5975 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
5976 {
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5977 char_u *str;
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5978 char_u buf[NUMBUFLEN];
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5979
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5980 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
5981 do_rubyeval(str, rettv);
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5982 }
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5983 #endif
518f44125207 patch 8.1.1056: no eval function for Ruby
Bram Moolenaar <Bram@vim.org>
parents: 16078
diff changeset
5984
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5985 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5986 * "screenattr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5987 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5988 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5989 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
5990 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5991 int row;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5992 int col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5993 int c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5994
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
5995 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
5996 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
5997 if (row < 0 || row >= screen_Rows
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5998 || col < 0 || col >= screen_Columns)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5999 c = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6000 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6001 c = ScreenAttrs[LineOffset[row] + col];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6002 rettv->vval.v_number = c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6003 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6004
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6005 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6006 * "screenchar()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6007 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6008 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6009 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
6010 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6011 int row;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6012 int col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6013 int off;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6014 int c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6015
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6016 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
6017 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
6018 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
6019 c = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6020 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6021 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6022 off = LineOffset[row] + col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6023 if (enc_utf8 && ScreenLinesUC[off] != 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6024 c = ScreenLinesUC[off];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6025 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6026 c = ScreenLines[off];
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 rettv->vval.v_number = c;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6029 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6030
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6031 /*
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6032 * "screenchars()" function
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6033 */
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6034 static void
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6035 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
6036 {
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6037 int row;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6038 int col;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6039 int off;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6040 int c;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6041 int i;
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 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
6044 return;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6045 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
6046 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
6047 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
6048 return;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6049
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6050 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
6051 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
6052 c = ScreenLinesUC[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6053 else
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6054 c = ScreenLines[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6055 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
6056
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6057 if (enc_utf8)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6058
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 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
6061 (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
6062 }
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6063
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6064 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6065 * "screencol()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6066 *
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6067 * 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
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_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
6071 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6072 rettv->vval.v_number = screen_screencol() + 1;
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
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 * "screenrow()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6079 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
6080 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6081 rettv->vval.v_number = screen_screenrow() + 1;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6084 /*
16133
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6085 * "screenstring()" function
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6086 */
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6087 static void
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6088 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
6089 {
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6090 int row;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6091 int col;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6092 int off;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6093 int c;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6094 int i;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6095 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
6096 int buflen = 0;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6097
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6098 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
6099 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
6100
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6101 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
6102 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
6103 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
6104 return;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6105
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6106 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
6107 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
6108 c = ScreenLinesUC[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6109 else
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6110 c = ScreenLines[off];
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6111 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
6112
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6113 if (enc_utf8)
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6114 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
6115 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
6116
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6117 buf[buflen] = NUL;
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6118 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
6119 }
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6120
eb087f8a26a8 patch 8.1.1071: cannot get composing characters from the screen
Bram Moolenaar <Bram@vim.org>
parents: 16127
diff changeset
6121 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6122 * "search()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6123 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6124 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6125 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
6126 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6127 int flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6128
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6129 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
6130 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6133 * "searchdecl()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6136 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
6137 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6138 int locally = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6139 int thisblock = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6140 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6141 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6142
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6143 rettv->vval.v_number = 1; /* default: FAIL */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6144
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6145 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
6146 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6147 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6148 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
6149 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
6150 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
6151 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6152 if (!error && name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6153 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
6154 locally, thisblock, SEARCH_KEEP) == FAIL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6155 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6156
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6157 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6158 * Used by searchpair() and searchpairpos()
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6159 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6160 static int
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6161 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
6162 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6163 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
6164 typval_T *skip;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6165 int save_p_ws = p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6166 int dir;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6167 int flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6168 char_u nbuf1[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6169 char_u nbuf2[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6170 int retval = 0; /* default: FAIL */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6171 long lnum_stop = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6172 long time_limit = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6173
14189
0181a2cad0a1 patch 8.1.0112: no error when using bad arguments with searchpair()
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
6174 /* 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
6175 * 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
6176 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
6177 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
6178 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
6179 if (spat == NULL || mpat == NULL || epat == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6180 goto theend; /* type error */
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 /* Handle the optional fourth argument: flags */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6183 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
6184 if (dir == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6185 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6186
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6187 /* 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
6188 * 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
6189 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6190 if ((flags & (SP_END | SP_SUBPAT)) != 0
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6191 || ((flags & SP_NOMOVE) && (flags & SP_SETPCMARK)))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6192 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6193 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
6194 goto theend;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6195 }
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 /* 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
6198 if (flags & SP_REPEAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6199 p_ws = FALSE;
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 /* Optional fifth argument: skip expression */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6202 if (argvars[3].v_type == VAR_UNKNOWN
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6203 || 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
6204 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
6205 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
6206 {
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6207 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
6208 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
6209 && 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
6210 {
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6211 /* Type error */
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6212 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
6213 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
6214 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6215 if (argvars[5].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6216 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6217 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
6218 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
6219 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6220 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
6221 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
6222 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6223 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6224 if (argvars[6].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6225 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6226 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
6227 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
6228 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6229 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
6230 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
6231 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6232 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6233 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6234 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6235 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6236
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6237 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
6238 match_pos, lnum_stop, time_limit);
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 theend:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6241 p_ws = save_p_ws;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6242
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6243 return retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6244 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6245
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6246 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6247 * "searchpair()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6248 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6249 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6250 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
6251 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6252 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
6253 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6254
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6255 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6256 * "searchpairpos()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6259 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
6260 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6261 pos_T match_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6262 int lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6263 int col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6264
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6265 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6266 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6267
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6268 if (searchpair_cmn(argvars, &match_pos) > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6269 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6270 lnum = match_pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6271 col = match_pos.col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6272 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6273
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6274 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
6275 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
6276 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6277
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6278 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6279 * Search for a start/middle/end thing.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6280 * 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
6281 * Returns 0 or -1 for no match,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6282 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6283 long
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6284 do_searchpair(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6285 char_u *spat, /* start pattern */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6286 char_u *mpat, /* middle pattern */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6287 char_u *epat, /* end pattern */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6288 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
6289 typval_T *skip, /* skip expression */
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6290 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
6291 pos_T *match_pos,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6292 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
6293 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
6294 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6295 char_u *save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6296 char_u *pat, *pat2 = NULL, *pat3 = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6297 long retval = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6298 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6299 pos_T firstpos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6300 pos_T foundpos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6301 pos_T save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6302 pos_T save_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6303 int n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6304 int r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6305 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
6306 int use_skip = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6307 int err;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6308 int options = SEARCH_KEEP;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6309 proftime_T tm;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6310
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6311 /* 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
6312 save_cpo = p_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6313 p_cpo = empty_option;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6314
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6315 #ifdef FEAT_RELTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6316 /* 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
6317 profile_setlimit(time_limit, &tm);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6318 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6319
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6320 /* 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
6321 * 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
6322 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
6323 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
6324 if (pat2 == NULL || pat3 == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6325 goto theend;
10514
1435e45ee6fa commit https://github.com/vim/vim/commit/6e450a57541676036203a72d40b2e604e938371e
Christian Brabandt <cb@256bit.org>
parents: 10501
diff changeset
6326 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
6327 if (*mpat == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6328 STRCPY(pat3, pat2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6329 else
10514
1435e45ee6fa commit https://github.com/vim/vim/commit/6e450a57541676036203a72d40b2e604e938371e
Christian Brabandt <cb@256bit.org>
parents: 10501
diff changeset
6330 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
6331 spat, epat, mpat);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6332 if (flags & SP_START)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6333 options |= SEARCH_START;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6334
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
6335 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
6336 {
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6337 /* 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
6338 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
6339 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
6340 && *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
6341 }
7749260f261c patch 8.0.1239: cannot use a lambda for the skip argument to searchpair()
Christian Brabandt <cb@256bit.org>
parents: 12716
diff changeset
6342
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6343 save_cursor = curwin->w_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6344 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
6345 CLEAR_POS(&firstpos);
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11105
diff changeset
6346 CLEAR_POS(&foundpos);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6347 pat = pat3;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6348 for (;;)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6349 {
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
6350 n = searchit(curwin, curbuf, &pos, NULL, dir, pat, 1L,
11521
578df034735d patch 8.0.0643: when a pattern search is slow Vim becomes unusable
Christian Brabandt <cb@256bit.org>
parents: 11519
diff changeset
6351 options, RE_SEARCH, lnum_stop, &tm, NULL);
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11105
diff changeset
6352 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
6353 /* 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
6354 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6355
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6356 if (firstpos.lnum == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6357 firstpos = pos;
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11105
diff changeset
6358 if (EQUAL_POS(pos, foundpos))
9571
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 /* 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
6361 * 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
6362 * character and try again. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6363 if (dir == BACKWARD)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6364 decl(&pos);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6365 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6366 incl(&pos);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6367 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6368 foundpos = pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6369
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6370 /* 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
6371 options &= ~SEARCH_START;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6372
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6373 /* 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
6374 if (use_skip)
9571
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 save_pos = curwin->w_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6377 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
6378 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
6379 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
6380 curwin->w_cursor = save_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6381 if (err)
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 /* Evaluating {skip} caused an error, break here. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6384 curwin->w_cursor = save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6385 retval = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6386 break;
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 if (r)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6389 continue;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6390 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6391
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6392 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
6393 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6394 /* 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
6395 * forward: nested pair. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6396 ++nest;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6397 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
6398 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6399 else
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 /* 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
6402 * 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
6403 if (--nest == 1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6404 pat = pat3; /* outer level, search for middle */
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6407 if (nest == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6408 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6409 /* 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
6410 if (flags & SP_RETCOUNT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6411 ++retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6412 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6413 retval = pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6414 if (flags & SP_SETPCMARK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6415 setpcmark();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6416 curwin->w_cursor = pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6417 if (!(flags & SP_REPEAT))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6418 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6419 nest = 1; /* search for next unmatched */
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6423 if (match_pos != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6424 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6425 /* Store the match cursor position */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6426 match_pos->lnum = curwin->w_cursor.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6427 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
6428 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6429
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6430 /* 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
6431 if ((flags & SP_NOMOVE) || retval == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6432 curwin->w_cursor = save_cursor;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6433
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6434 theend:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6435 vim_free(pat2);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6436 vim_free(pat3);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6437 if (p_cpo == empty_option)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6438 p_cpo = save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6439 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6440 /* 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
6441 free_string_option(save_cpo);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6442
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6443 return retval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6444 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6447 * "searchpos()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6448 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6449 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6450 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
6451 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6452 pos_T match_pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6453 int lnum = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6454 int col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6455 int n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6456 int flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6457
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6458 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6459 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6460
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6461 n = search_cmn(argvars, &match_pos, &flags);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6462 if (n > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6463 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6464 lnum = match_pos.lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6465 col = match_pos.col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6466 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6467
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6468 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
6469 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
6470 if (flags & SP_SUBPAT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6471 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
6472 }
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6475 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
6476 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6477 #ifdef FEAT_CLIENTSERVER
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6478 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
6479 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
6480 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
6481
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6482 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6483 if (server == NULL || reply == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6484 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6485 if (check_restricted() || check_secure())
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6486 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6487 # ifdef FEAT_X11
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6488 if (check_connection() == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6489 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6490 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6491
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6492 if (serverSendReply(server, reply) < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6493 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6494 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
6495 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6496 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6497 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6498 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6499 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6500 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6501 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6502
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6503 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6504 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
6505 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6506 char_u *r = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6507
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6508 #ifdef FEAT_CLIENTSERVER
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
6509 # ifdef MSWIN
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6510 r = serverGetVimNames();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6511 # else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6512 make_connection();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6513 if (X_DISPLAY != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6514 r = serverGetVimNames(X_DISPLAY);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6515 # endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6516 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6517 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6518 rettv->vval.v_string = r;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6519 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6520
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6521 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6522 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
6523 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6524 dict_T *d;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6525 dictitem_T *di;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6526 char_u *csearch;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6527
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6528 if (argvars[0].v_type != VAR_DICT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6529 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6530 emsg(_(e_dictreq));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6531 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6532 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6533
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6534 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
6535 {
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
6536 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
6537 if (csearch != NULL)
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 if (enc_utf8)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6540 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6541 int pcc[MAX_MCO];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6542 int c = utfc_ptr2char(csearch, pcc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6543
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6544 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
6545 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6546 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6547 set_last_csearch(PTR2CHAR(csearch),
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6548 csearch, MB_PTR2LEN(csearch));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6549 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6550
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6551 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
6552 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
6553 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
6554 ? FORWARD : BACKWARD);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6555
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6556 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
6557 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
6558 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
6559 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6560 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6561
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6562 /*
16604
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6563 * "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
6564 */
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6565 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
6566 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
6567 {
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6568 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
6569 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
6570 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
6571
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6572 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
6573 && 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
6574 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
6575 else
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6576 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
6577 }
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6578
1e0a5f09fdf1 patch 8.1.1305: there is no easy way to manipulate environment variables
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
6579 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6580 * "setfperm({fname}, {mode})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6581 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6582 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6583 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
6584 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6585 char_u *fname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6586 char_u modebuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6587 char_u *mode_str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6588 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6589 int mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6590 int mode = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6591
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6592 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
6593 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
6594 if (fname == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6595 return;
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6596 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
6597 if (mode_str == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6598 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6599 if (STRLEN(mode_str) != 9)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6600 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6601 semsg(_(e_invarg2), mode_str);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6602 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6603 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6604
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6605 mask = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6606 for (i = 8; i >= 0; --i)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6607 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6608 if (mode_str[i] != '-')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6609 mode |= mask;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6610 mask = mask << 1;
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 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
6613 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6616 * "setpos()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6619 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
6620 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6621 pos_T pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6622 int fnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6623 char_u *name;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6624 colnr_T curswant = -1;
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 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
6627 name = tv_get_string_chk(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6628 if (name != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6629 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6630 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
6631 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6632 if (--pos.col < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6633 pos.col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6634 if (name[0] == '.' && name[1] == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6635 {
10732
390ad2cccd3f patch 8.0.0256: missing changes to one file breaks test
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
6636 /* 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
6637 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
6638 if (curswant >= 0)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6639 {
10732
390ad2cccd3f patch 8.0.0256: missing changes to one file breaks test
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
6640 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
6641 curwin->w_set_curswant = FALSE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6642 }
10732
390ad2cccd3f patch 8.0.0256: missing changes to one file breaks test
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
6643 check_cursor();
390ad2cccd3f patch 8.0.0256: missing changes to one file breaks test
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
6644 rettv->vval.v_number = 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6645 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6646 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
6647 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6648 /* set mark */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6649 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
6650 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6651 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6652 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6653 emsg(_(e_invarg));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6654 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6655 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6656 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6657
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6658 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6659 * "setreg()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6660 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6661 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6662 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
6663 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6664 int regname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6665 char_u *strregname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6666 char_u *stropt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6667 char_u *strval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6668 int append;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6669 char_u yank_type;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6670 long block_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6671
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6672 block_len = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6673 yank_type = MAUTO;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6674 append = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6675
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6676 strregname = tv_get_string_chk(argvars);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6677 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
6678
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6679 if (strregname == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6680 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6681 regname = *strregname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6682 if (regname == 0 || regname == '@')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6683 regname = '"';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6684
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6685 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6686 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6687 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
6688 if (stropt == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6689 return; /* type error */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6690 for (; *stropt != NUL; ++stropt)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6691 switch (*stropt)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6692 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6693 case 'a': case 'A': /* append */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6694 append = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6695 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6696 case 'v': case 'c': /* character-wise selection */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6697 yank_type = MCHAR;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6698 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6699 case 'V': case 'l': /* line-wise selection */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6700 yank_type = MLINE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6701 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6702 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
6703 yank_type = MBLOCK;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6704 if (VIM_ISDIGIT(stropt[1]))
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 ++stropt;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6707 block_len = getdigits(&stropt) - 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6708 --stropt;
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 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6711 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6712 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6713
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6714 if (argvars[1].v_type == VAR_LIST)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6715 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6716 char_u **lstval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6717 char_u **allocval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6718 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6719 char_u **curval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6720 char_u **curallocval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6721 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
6722 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6723 int 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 /* 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
6726 len = ll == NULL ? 0 : ll->lv_len;
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 /* 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
6729 * 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
6730 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
6731 if (lstval == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6732 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6733 curval = lstval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6734 allocval = lstval + len + 2;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6735 curallocval = allocval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6736
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6737 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
6738 li = li->li_next)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6739 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6740 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
6741 if (strval == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6742 goto free_lstval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6743 if (strval == buf)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6744 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6745 /* 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
6746 * overwrite the string. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6747 strval = vim_strsave(buf);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6748 if (strval == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6749 goto free_lstval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6750 *curallocval++ = strval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6751 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6752 *curval++ = strval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6753 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6754 *curval++ = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6755
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6756 write_reg_contents_lst(regname, lstval, -1,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6757 append, yank_type, block_len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6758 free_lstval:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6759 while (curallocval > allocval)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6760 vim_free(*--curallocval);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6761 vim_free(lstval);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6762 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6763 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6764 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6765 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
6766 if (strval == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6767 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6768 write_reg_contents_ex(regname, strval, -1,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6769 append, yank_type, block_len);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6770 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6771 rettv->vval.v_number = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6772 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6773
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6774 /*
15016
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6775 * "settagstack()" function
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6776 */
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6777 static void
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6778 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
6779 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6780 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
6781 win_T *wp;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6782 dict_T *d;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6783 int action = 'r';
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6784
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6785 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
6786
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6787 // 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
6788 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
6789 if (wp == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6790 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6791
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6792 // 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
6793 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
6794 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6795 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
6796 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6797 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6798 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
6799 if (d == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6800 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6801
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6802 // 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
6803 // 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
6804 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
6805 action = 'r';
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6806 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
6807 {
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6808 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
6809 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
6810 if (actstr == NULL)
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6811 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6812 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
6813 action = *actstr;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6814 else
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6815 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6816 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
6817 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6818 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6819 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6820 else
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6821 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
6822 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
6823 return;
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6824 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6825
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6826 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
6827 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
6828 }
c338c91086b9 patch 8.1.0519: cannot save and restore the tag stack
Bram Moolenaar <Bram@vim.org>
parents: 14966
diff changeset
6829
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6830 #ifdef FEAT_CRYPT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6831 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6832 * "sha256({string})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6833 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6834 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6835 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
6836 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6837 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6838
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6839 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6840 rettv->vval.v_string = vim_strsave(
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6841 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
6842 rettv->v_type = VAR_STRING;
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 #endif /* FEAT_CRYPT */
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6847 * "shellescape({string})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6848 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6849 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6850 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
6851 {
11484
3933a3bf9385 patch 8.0.0625: shellescape() always escapes a newline
Christian Brabandt <cb@256bit.org>
parents: 11461
diff changeset
6852 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
6853
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6854 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
6855 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
6856 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6857 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6860 * shiftwidth() function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6861 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6862 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6863 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
6864 {
15062
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6865 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
6866
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6867 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
6868 {
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6869 long col;
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6870
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6871 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
6872 if (col < 0)
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6873 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
6874 #ifdef FEAT_VARTABS
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6875 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
6876 return;
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6877 #endif
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6878 }
3a94f7918980 patch 8.1.0542: shiftwidth() does not take 'vartabstop' into account
Bram Moolenaar <Bram@vim.org>
parents: 15020
diff changeset
6879
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6880 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
6881 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6882
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6883 #ifdef FEAT_FLOAT
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 * "sin()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6888 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
6889 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6890 float_T f = 0.0;
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 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6893 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6894 rettv->vval.v_float = sin(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6895 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6896 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6897 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6898
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6899 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6900 * "sinh()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6903 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
6904 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6905 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6906
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6907 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6908 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6909 rettv->vval.v_float = sinh(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6910 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6911 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6912 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6913 #endif
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6916 * "soundfold({word})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6917 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6918 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6919 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
6920 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6921 char_u *s;
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 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
6924 s = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6925 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6926 rettv->vval.v_string = eval_soundfold(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6927 #else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6928 rettv->vval.v_string = vim_strsave(s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6929 #endif
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6933 * "spellbadword()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6934 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6935 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6936 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
6937 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6938 char_u *word = (char_u *)"";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6939 hlf_T attr = HLF_COUNT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6940 int len = 0;
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 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6943 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6944
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6945 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6946 if (argvars[0].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6947 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6948 /* 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
6949 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
6950 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
6951 {
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6952 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
6953 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
6954 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6955 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6956 else 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
6957 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
6958 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
6959 int capcol = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6960
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6961 if (str != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6962 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6963 /* Check the argument for spelling. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6964 while (*str != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6965 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6966 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
6967 if (attr != HLF_COUNT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6968 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6969 word = str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6970 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6971 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6972 str += len;
14368
e78ce11f310b patch 8.1.0199: spellbadword() does not check for caps error
Christian Brabandt <cb@256bit.org>
parents: 14343
diff changeset
6973 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
6974 len = 0;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6975 }
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6979
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6980 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
6981 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
6982 attr == HLF_SPB ? "bad" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6983 attr == HLF_SPR ? "rare" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6984 attr == HLF_SPL ? "local" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6985 attr == HLF_SPC ? "caps" :
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6986 ""), -1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6987 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6988
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6989 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6990 * "spellsuggest()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6993 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
6994 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6995 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6996 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6997 int typeerr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6998 int maxcount;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6999 garray_T ga;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7000 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7001 listitem_T *li;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7002 int need_capital = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7003 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7004
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7005 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7006 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7007
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7008 #ifdef FEAT_SPELL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7009 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
7010 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7011 str = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7012 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7013 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7014 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
7015 if (maxcount <= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7016 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7017 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7018 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7019 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
7020 if (typeerr)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7021 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7022 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7023 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7024 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7025 maxcount = 25;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7026
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7027 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
7028
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7029 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
7030 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7031 str = ((char_u **)ga.ga_data)[i];
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 li = listitem_alloc();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7034 if (li == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7035 vim_free(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7036 else
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 li->li_tv.v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7039 li->li_tv.v_lock = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7040 li->li_tv.vval.v_string = str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7041 list_append(rettv->vval.v_list, li);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7042 }
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 ga_clear(&ga);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7045 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7046 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7047 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7048
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7049 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7050 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
7051 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7052 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7053 char_u *end;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7054 char_u *pat = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7055 regmatch_T regmatch;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7056 char_u patbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7057 char_u *save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7058 int match;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7059 colnr_T col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7060 int keepempty = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7061 int typeerr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7062
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7063 /* 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
7064 save_cpo = p_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7065 p_cpo = (char_u *)"";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7066
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7067 str = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7068 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7069 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7070 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
7071 if (pat == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7072 typeerr = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7073 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
7074 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
7075 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7076 if (pat == NULL || *pat == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7077 pat = (char_u *)"[\\x01- ]\\+";
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7078
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7079 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7080 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7081 if (typeerr)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7082 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7083
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7084 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
7085 if (regmatch.regprog != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7086 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7087 regmatch.rm_ic = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7088 while (*str != NUL || keepempty)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7089 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7090 if (*str == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7091 match = FALSE; /* empty item at the end */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7092 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7093 match = vim_regexec_nl(&regmatch, str, col);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7094 if (match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7095 end = regmatch.startp[0];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7096 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7097 end = str + STRLEN(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7098 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
7099 && *str != NUL && match && end < regmatch.endp[0]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7100 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7101 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
7102 (int)(end - str)) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7103 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7104 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7105 if (!match)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7106 break;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7107 // Advance to just after the match.
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7108 if (regmatch.endp[0] > str)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7109 col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7110 else
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7111 // 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
7112 col = (*mb_ptr2len)(regmatch.endp[0]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7113 str = regmatch.endp[0];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7114 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7115
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7116 vim_regfree(regmatch.regprog);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7117 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7118
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7119 p_cpo = save_cpo;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7120 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7121
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7122 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7123 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7124 * "sqrt()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7125 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7126 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7127 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
7128 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7129 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7130
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7131 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7132 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7133 rettv->vval.v_float = sqrt(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7134 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7135 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7136 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7137
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7138 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7139 * "str2float()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7140 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7141 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7142 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
7143 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7144 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
7145 int isneg = (*p == '-');
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7146
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7147 if (*p == '+' || *p == '-')
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7148 p = skipwhite(p + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7149 (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
7150 if (isneg)
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7151 rettv->vval.v_float *= -1;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7152 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7153 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7154 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7155
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7156 /*
16235
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7157 * "str2list()" function
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7158 */
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7159 static void
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7160 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
7161 {
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7162 char_u *p;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7163 int utf8 = FALSE;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7164
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7165 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
7166 return;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7167
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7168 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
7169 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
7170
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7171 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
7172
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7173 if (has_mbyte || utf8)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7174 {
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7175 int (*ptr2len)(char_u *);
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7176 int (*ptr2char)(char_u *);
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7177
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7178 if (utf8 || enc_utf8)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7179 {
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7180 ptr2len = utf_ptr2len;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7181 ptr2char = utf_ptr2char;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7182 }
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7183 else
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 ptr2len = mb_ptr2len;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7186 ptr2char = mb_ptr2char;
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7187 }
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 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
7190 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
7191 }
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7192 else
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7193 for ( ; *p != NUL; ++p)
219c58b3879c patch 8.1.1122: char2nr() does not handle composing characters
Bram Moolenaar <Bram@vim.org>
parents: 16231
diff changeset
7194 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
7195 }
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 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7198 * "str2nr()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7199 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7200 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7201 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
7202 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7203 int base = 10;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7204 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7205 varnumber_T n;
18080
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
7206 int what = 0;
10555
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7207 int isneg;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7208
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7209 if (argvars[1].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7210 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7211 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
7212 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
7213 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
7214 emsg(_(e_invarg));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7215 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7216 }
18080
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
7217 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
7218 what |= STR2NR_QUOTE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7219 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7220
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7221 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
7222 isneg = (*p == '-');
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7223 if (*p == '+' || *p == '-')
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7224 p = skipwhite(p + 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7225 switch (base)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7226 {
18080
a6d218f99ff7 patch 8.1.2035: recognizing octal numbers is confusing
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
7227 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
7228 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
7229 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
7230 }
16706
77bcb5055fec patch 8.1.1355: obvious mistakes are accepted as valid expressions
Bram Moolenaar <Bram@vim.org>
parents: 16700
diff changeset
7231 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
7232 // 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
7233 if (isneg)
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7234 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
7235 else
fff45421182b patch 8.0.0167: str2nr()/str2float() fail with negative values
Christian Brabandt <cb@256bit.org>
parents: 10553
diff changeset
7236 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
7237
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7238 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7239
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7240 #ifdef HAVE_STRFTIME
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7241 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7242 * "strftime({format}[, {time}])" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7243 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7244 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7245 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
7246 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7247 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
7248 struct tm tmval;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7249 struct tm *curtime;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7250 time_t seconds;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7251 char_u *p;
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 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7254
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7255 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7256 if (argvars[1].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7257 seconds = time(NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7258 else
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7259 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
7260 curtime = vim_localtime(&seconds, &tmval);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7261 /* 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
7262 if (curtime == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7263 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
7264 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7265 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7266 vimconv_T conv;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7267 char_u *enc;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7268
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7269 conv.vc_type = CONV_NONE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7270 enc = enc_locale();
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7271 convert_setup(&conv, p_enc, enc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7272 if (conv.vc_type != CONV_NONE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7273 p = string_convert(&conv, p, NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7274 if (p != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7275 (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
7276 (char *)p, curtime);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7277 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7278 result_buf[0] = NUL;
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 if (conv.vc_type != CONV_NONE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7281 vim_free(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7282 convert_setup(&conv, enc, p_enc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7283 if (conv.vc_type != CONV_NONE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7284 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
7285 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7286 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
7287
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7288 /* Release conversion descriptors */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7289 convert_setup(&conv, NULL, NULL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7290 vim_free(enc);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7291 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7292 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7293 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7294
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7295 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7296 * "strgetchar()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7297 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7298 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7299 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
7300 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7301 char_u *str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7302 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7303 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7304 int charidx;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7305 int byteidx = 0;
9571
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 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
7308 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
7309 if (str == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7310 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7311 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
7312 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
7313 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7314 return;
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7315
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7316 while (charidx >= 0 && byteidx < len)
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7317 {
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7318 if (charidx == 0)
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7319 {
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7320 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
7321 break;
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7322 }
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7323 --charidx;
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7324 byteidx += MB_CPTR2LEN(str + byteidx);
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7325 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7326 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7327
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7328 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7329 * "stridx()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7330 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7331 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7332 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
7333 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7334 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7335 char_u *needle;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7336 char_u *haystack;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7337 char_u *save_haystack;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7338 char_u *pos;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7339 int start_idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7340
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7341 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
7342 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
7343 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7344 if (needle == NULL || haystack == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7345 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7346
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7347 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7348 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7349 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7350
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7351 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
7352 if (error || start_idx >= (int)STRLEN(haystack))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7353 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7354 if (start_idx >= 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7355 haystack += start_idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7356 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7357
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7358 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
7359 if (pos != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7360 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
7361 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7364 * "string()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7365 */
15219
dada0b389d4f patch 8.1.0619: :echomsg and :echoerr do not handle List and Dict
Bram Moolenaar <Bram@vim.org>
parents: 15211
diff changeset
7366 void
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7367 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
7368 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7369 char_u *tofree;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7370 char_u numbuf[NUMBUFLEN];
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 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7373 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
7374 get_copyID());
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7375 /* 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
7376 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
7377 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
7378 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7379
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7380 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7381 * "strlen()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7384 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
7385 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7386 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
7387 tv_get_string(&argvars[0])));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7388 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7389
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7390 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7391 * "strchars()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7394 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
7395 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7396 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
7397 int skipcc = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7398 varnumber_T len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7399 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
7400
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7401 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
7402 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
7403 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
7404 emsg(_(e_invarg));
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7405 else
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 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
7408 while (*s != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7409 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7410 func_mb_ptr2char_adv(&s);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7411 ++len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7412 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7413 rettv->vval.v_number = len;
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 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7416
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7417 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7418 * "strdisplaywidth()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7419 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7420 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7421 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
7422 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7423 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
7424 int col = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7425
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7426 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
7427 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
7428
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7429 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
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7433 * "strwidth()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7434 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7435 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7436 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
7437 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7438 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
7439
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15579
diff changeset
7440 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
7441 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7444 * "strcharpart()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7447 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
7448 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7449 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7450 int nchar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7451 int nbyte = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7452 int charlen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7453 int len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7454 int slen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7455 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7456
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7457 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7458 slen = (int)STRLEN(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7459
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7460 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
7461 if (!error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7462 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7463 if (nchar > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7464 while (nchar > 0 && nbyte < slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7465 {
9898
bff8a09016a5 commit https://github.com/vim/vim/commit/d3c907b5d2b352482b580a0cf687cbbea4c19ea1
Christian Brabandt <cb@256bit.org>
parents: 9881
diff changeset
7466 nbyte += MB_CPTR2LEN(p + nbyte);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7467 --nchar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7468 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7469 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7470 nbyte = nchar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7471 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7472 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7473 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
7474 while (charlen > 0 && nbyte + len < slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7475 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7476 int off = nbyte + len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7477
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7478 if (off < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7479 len += 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7480 else
9898
bff8a09016a5 commit https://github.com/vim/vim/commit/d3c907b5d2b352482b580a0cf687cbbea4c19ea1
Christian Brabandt <cb@256bit.org>
parents: 9881
diff changeset
7481 len += MB_CPTR2LEN(p + off);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7482 --charlen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7483 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7484 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7485 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7486 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
7487 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7488
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 * 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
7491 * string.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7492 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7493 if (nbyte < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7494 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7495 len += nbyte;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7496 nbyte = 0;
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 else if (nbyte > slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7499 nbyte = slen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7500 if (len < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7501 len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7502 else if (nbyte + len > slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7503 len = slen - nbyte;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7504
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7505 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7506 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
7507 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7508
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7509 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7510 * "strpart()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7513 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
7514 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7515 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7516 int n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7517 int len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7518 int slen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7519 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7520
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7521 p = tv_get_string(&argvars[0]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7522 slen = (int)STRLEN(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7523
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7524 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
7525 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7526 len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7527 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
7528 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
7529 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7530 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
7531
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7532 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7533 * 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
7534 * string.
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7535 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7536 if (n < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7537 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7538 len += n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7539 n = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7540 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7541 else if (n > slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7542 n = slen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7543 if (len < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7544 len = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7545 else if (n + len > slen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7546 len = slen - n;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7547
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7548 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7549 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
7550 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7551
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7552 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7553 * "strridx()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7556 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
7557 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7558 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7559 char_u *needle;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7560 char_u *haystack;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7561 char_u *rest;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7562 char_u *lastmatch = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7563 int haystack_len, end_idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7564
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7565 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
7566 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
7567
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7568 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7569 if (needle == NULL || haystack == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7570 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7572 haystack_len = (int)STRLEN(haystack);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7573 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7574 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7575 /* 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
7576 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
7577 if (end_idx < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7578 return; /* can never find a match */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7579 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7580 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7581 end_idx = haystack_len;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7582
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7583 if (*needle == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7584 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7585 /* Empty string matches past the end. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7586 lastmatch = haystack + end_idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7587 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7588 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7589 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7590 for (rest = haystack; *rest != '\0'; ++rest)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7591 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7592 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
7593 if (rest == NULL || rest > haystack + end_idx)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7594 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7595 lastmatch = rest;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7596 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7597 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7598
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7599 if (lastmatch == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7600 rettv->vval.v_number = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7601 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7602 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
7603 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7604
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 * "strtrans()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7607 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7608 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7609 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
7610 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7611 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
7612 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
7613 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7614
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7615 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7616 * "submatch()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7617 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7618 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7619 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
7620 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7621 int error = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7622 int no;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7623 int retList = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7624
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7625 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
7626 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7627 return;
9923
935e13935848 commit https://github.com/vim/vim/commit/989f592f7ffcbafdc4ec35cee4dc65bd053e2077
Christian Brabandt <cb@256bit.org>
parents: 9919
diff changeset
7628 if (no < 0 || no >= NSUBEXP)
935e13935848 commit https://github.com/vim/vim/commit/989f592f7ffcbafdc4ec35cee4dc65bd053e2077
Christian Brabandt <cb@256bit.org>
parents: 9919
diff changeset
7629 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
7630 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
7631 return;
9923
935e13935848 commit https://github.com/vim/vim/commit/989f592f7ffcbafdc4ec35cee4dc65bd053e2077
Christian Brabandt <cb@256bit.org>
parents: 9919
diff changeset
7632 }
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7633 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
7634 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
7635 if (error)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7636 return;
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 if (retList == 0)
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 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7641 rettv->vval.v_string = reg_submatch(no);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7642 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7643 else
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 rettv->v_type = VAR_LIST;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7646 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
7647 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7648 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7649
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7650 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7651 * "substitute()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7654 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
7655 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7656 char_u patbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7657 char_u subbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7658 char_u flagsbuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7659
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7660 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
7661 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
7662 char_u *sub = NULL;
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7663 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
7664 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
7665
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7666 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
7667 expr = &argvars[2];
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7668 else
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7669 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
7670
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7671 rettv->v_type = VAR_STRING;
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7672 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
7673 || flg == NULL)
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7674 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7675 else
9589
bf204ab1ce7d commit https://github.com/vim/vim/commit/72ab729c3dcdea0fba44d8e676602c847e841bcd
Christian Brabandt <cb@256bit.org>
parents: 9587
diff changeset
7676 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
7677 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7678
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7679 /*
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7680 * "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
7681 */
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7682 static void
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7683 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
7684 {
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7685 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
7686 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
7687 }
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7688
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 14587
diff changeset
7689 /*
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7690 * "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
7691 */
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7692 static void
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7693 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
7694 {
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7695 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
7696
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7697 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
7698 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
7699 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
7700 || 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
7701 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
7702 else
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7703 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
7704 }
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7705
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14756
diff changeset
7706 /*
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7707 * "synID(lnum, col, trans)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7708 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7709 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7710 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
7711 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7712 int id = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7713 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7714 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7715 colnr_T col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7716 int trans;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7717 int transerr = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7718
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7719 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
7720 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
7721 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
7722
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7723 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
7724 && 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
7725 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
7726 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7727
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7728 rettv->vval.v_number = id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7729 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7730
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7731 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7732 * "synIDattr(id, what [, mode])" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7733 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7734 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7735 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
7736 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7737 char_u *p = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7738 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7739 int id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7740 char_u *what;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7741 char_u *mode;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7742 char_u modebuf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7743 int modec;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7744
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7745 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
7746 what = tv_get_string(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7747 if (argvars[2].v_type != VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7748 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7749 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
7750 modec = TOLOWER_ASC(mode[0]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7751 if (modec != 't' && modec != 'c' && modec != 'g')
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7752 modec = 0; /* replace invalid with current */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7753 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7754 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7755 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7756 #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7757 if (USE_24BIT)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7758 modec = 'g';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7759 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7760 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7761 if (t_colors > 1)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7762 modec = 'c';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7763 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7764 modec = 't';
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7765 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7766
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7767 switch (TOLOWER_ASC(what[0]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7768 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7769 case 'b':
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7770 if (TOLOWER_ASC(what[1]) == 'g') /* bg[#] */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7771 p = highlight_color(id, what, modec);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7772 else /* bold */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7773 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
7774 break;
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 case 'f': /* fg[#] or font */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7777 p = highlight_color(id, what, modec);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7778 break;
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 case 'i':
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7781 if (TOLOWER_ASC(what[1]) == 'n') /* inverse */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7782 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
7783 else /* italic */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7784 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
7785 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7786
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7787 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
7788 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
7789 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7790
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7791 case 'r': /* reverse */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7792 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
7793 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7794
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7795 case 's':
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7796 if (TOLOWER_ASC(what[1]) == 'p') /* sp[#] */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7797 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
7798 /* strikeout */
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
7799 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
7800 TOLOWER_ASC(what[2]) == 'r')
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12252
diff changeset
7801 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
7802 else /* standout */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7803 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
7804 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7805
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7806 case 'u':
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7807 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
7808 /* underline */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7809 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
7810 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7811 /* undercurl */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7812 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
7813 break;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7816 if (p != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7817 p = vim_strsave(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7818 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7819 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7820 rettv->vval.v_string = p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7821 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7822
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 * "synIDtrans(id)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7825 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7826 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7827 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
7828 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7829 int id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7830
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7831 #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
7832 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
7833
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7834 if (id > 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7835 id = syn_get_final_id(id);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7836 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7837 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7838 id = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7839
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7840 rettv->vval.v_number = id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7841 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7844 * "synconcealed(lnum, col)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7845 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7846 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7847 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
7848 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7849 #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
7850 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7851 colnr_T col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7852 int syntax_flags = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7853 int cchar;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7854 int matchid = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7855 char_u str[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7856 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7857
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
7858 rettv_list_set(rettv, NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7859
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7860 #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
7861 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
7862 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
7863
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7864 vim_memset(str, NUL, sizeof(str));
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7865
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7866 if (rettv_list_alloc(rettv) != FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7867 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7868 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
7869 && 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
7870 && curwin->w_p_cole > 0)
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 (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
7873 syntax_flags = get_syntax_info(&matchid);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7874
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7875 /* get the conceal character */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7876 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
7877 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7878 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
7879 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
7880 cchar = (lcs_conceal == NUL) ? ' ' : lcs_conceal;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7881 if (cchar != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7882 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7883 if (has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7884 (*mb_char2bytes)(cchar, str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7885 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7886 str[0] = cchar;
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 }
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 list_append_number(rettv->vval.v_list,
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7892 (syntax_flags & HL_CONCEAL) != 0);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7893 /* -1 to auto-determine strlen */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7894 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
7895 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
7896 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7897 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7898 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7899
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7900 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7901 * "synstack(lnum, col)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7902 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7903 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7904 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
7905 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7906 #ifdef FEAT_SYN_HL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7907 linenr_T lnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7908 colnr_T col;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7909 int i;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7910 int id;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7911 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7912
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
7913 rettv_list_set(rettv, NULL);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7914
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7915 #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
7916 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
7917 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
7918
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7919 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
7920 && 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
7921 && rettv_list_alloc(rettv) != FAIL)
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 (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
7924 for (i = 0; ; ++i)
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 id = syn_get_stack_item(i);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7927 if (id < 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7928 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7929 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
7930 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7931 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7932 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7933 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7934 }
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 * "tabpagebuflist()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7940 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
7941 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7942 tabpage_T *tp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7943 win_T *wp = NULL;
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 if (argvars[0].v_type == VAR_UNKNOWN)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7946 wp = firstwin;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7947 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7948 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7949 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
7950 if (tp != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7951 wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7952 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7953 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
7954 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7955 for (; wp != NULL; wp = wp->w_next)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7956 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
7957 wp->w_buffer->b_fnum) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7958 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7959 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7960 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7961
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 * "tagfiles()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7964 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7965 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7966 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
7967 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7968 char_u *fname;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7969 tagname_T tn;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7970 int first;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7971
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7972 if (rettv_list_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7973 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7974 fname = alloc(MAXPATHL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7975 if (fname == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7976 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7977
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7978 for (first = TRUE; ; first = FALSE)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7979 if (get_tagfname(&tn, first, fname) == FAIL
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7980 || 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
7981 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7982 tagname_free(&tn);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7983 vim_free(fname);
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
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 * "taglist()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7988 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7989 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7990 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
7991 {
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents: 11215
diff changeset
7992 char_u *fname = NULL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7993 char_u *tag_pattern;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7994
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
7995 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
7996
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7997 rettv->vval.v_number = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7998 if (*tag_pattern == NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7999 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8000
11225
d3415ec1cdaf patch 8.0.0499: taglist() does not prioritize tags for a buffer
Christian Brabandt <cb@256bit.org>
parents: 11215
diff changeset
8001 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
8002 fname = tv_get_string(&argvars[1]);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8003 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
8004 (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
8005 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8006
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8007 #ifdef FEAT_FLOAT
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 * "tan()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8012 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
8013 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8014 float_T f = 0.0;
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 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8017 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8018 rettv->vval.v_float = tan(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8019 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8020 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8021 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8022
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8023 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8024 * "tanh()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8027 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
8028 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8029 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8030
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8031 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8032 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8033 rettv->vval.v_float = tanh(f);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8034 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8035 rettv->vval.v_float = 0.0;
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 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8038
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8039 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8040 * "tolower(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8041 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8042 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8043 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
8044 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8045 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
8046 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
8047 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8048
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8049 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8050 * "toupper(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8051 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8052 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8053 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
8054 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8055 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
8056 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
8057 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8060 * "tr(string, fromstr, tostr)" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8063 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
8064 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8065 char_u *in_str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8066 char_u *fromstr;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8067 char_u *tostr;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8068 char_u *p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8069 int inlen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8070 int fromlen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8071 int tolen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8072 int idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8073 char_u *cpstr;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8074 int cplen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8075 int first = TRUE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8076 char_u buf[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8077 char_u buf2[NUMBUFLEN];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8078 garray_T ga;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8079
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8080 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
8081 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
8082 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
8083
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8084 /* Default return value: empty string. */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8085 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8086 rettv->vval.v_string = NULL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8087 if (fromstr == NULL || tostr == NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8088 return; /* type error; errmsg already given */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8089 ga_init2(&ga, (int)sizeof(char), 80);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8090
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8091 if (!has_mbyte)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8092 /* 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
8093 if (STRLEN(fromstr) != STRLEN(tostr))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8094 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8095 error:
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15468
diff changeset
8096 semsg(_(e_invarg2), fromstr);
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8097 ga_clear(&ga);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8098 return;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8101 /* 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
8102 while (*in_str != NUL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8103 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8104 if (has_mbyte)
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 inlen = (*mb_ptr2len)(in_str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8107 cpstr = in_str;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8108 cplen = inlen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8109 idx = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8110 for (p = fromstr; *p != NUL; p += fromlen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8111 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8112 fromlen = (*mb_ptr2len)(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8113 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
8114 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8115 for (p = tostr; *p != NUL; p += tolen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8116 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8117 tolen = (*mb_ptr2len)(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8118 if (idx-- == 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8119 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8120 cplen = tolen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8121 cpstr = p;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8122 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8123 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8124 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8125 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
8126 goto error;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8127 break;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8128 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8129 ++idx;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8130 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8131
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8132 if (first && cpstr == in_str)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8133 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8134 /* 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
8135 * (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
8136 * 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
8137 first = FALSE;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8138 for (p = tostr; *p != NUL; p += tolen)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8139 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8140 tolen = (*mb_ptr2len)(p);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8141 --idx;
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 if (idx != 0)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8144 goto error;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8145 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8146
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8147 (void)ga_grow(&ga, cplen);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8148 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
8149 ga.ga_len += cplen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8150
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8151 in_str += inlen;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8152 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8153 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8154 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8155 /* 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
8156 p = vim_strchr(fromstr, *in_str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8157 if (p != NULL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8158 ga_append(&ga, tostr[p - fromstr]);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8159 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8160 ga_append(&ga, *in_str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8161 ++in_str;
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 }
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 /* add a terminating NUL */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8166 (void)ga_grow(&ga, 1);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8167 ga_append(&ga, NUL);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8168
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8169 rettv->vval.v_string = ga.ga_data;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8170 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8171
13513
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8172 /*
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8173 * "trim({expr})" function
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8174 */
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8175 static void
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8176 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
8177 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8178 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
8179 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
8180 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
8181 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
8182 char_u *tail;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8183 char_u *prev;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8184 char_u *p;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8185 int c1;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8186
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8187 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
8188 if (head == NULL)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8189 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8190 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
8191 return;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8192 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8193
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8194 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
8195 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
8196
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8197 while (*head != NUL)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8198 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8199 c1 = PTR2CHAR(head);
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8200 if (mask == NULL)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8201 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8202 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
8203 break;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8204 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8205 else
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8206 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8207 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
8208 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
8209 break;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8210 if (*p == NUL)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8211 break;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8212 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8213 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
8214 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8215
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8216 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
8217 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8218 prev = tail;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8219 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
8220 c1 = PTR2CHAR(prev);
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8221 if (mask == NULL)
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 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
8224 break;
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 else
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8227 {
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8228 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
8229 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
8230 break;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8231 if (*p == NUL)
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8232 break;
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8233 }
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->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
8236 }
4064f342bea4 patch 8.0.1630: trimming white space is not that easy
Christian Brabandt <cb@256bit.org>
parents: 13470
diff changeset
8237
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8238 #ifdef FEAT_FLOAT
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8239 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8240 * "trunc({float})" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8241 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8242 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8243 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
8244 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8245 float_T f = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8246
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8247 rettv->v_type = VAR_FLOAT;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8248 if (get_float_arg(argvars, &f) == OK)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8249 /* 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
8250 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
8251 else
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8252 rettv->vval.v_float = 0.0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8253 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8254 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8255
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8256 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8257 * "type(expr)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8258 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8259 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8260 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
8261 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8262 int n = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8263
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8264 switch (argvars[0].v_type)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8265 {
9587
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8266 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
8267 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
8268 case VAR_PARTIAL:
9587
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8269 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
8270 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
8271 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
8272 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
8273 case VAR_SPECIAL:
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8274 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
8275 || 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
8276 n = VAR_TYPE_BOOL;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8277 else
9587
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8278 n = VAR_TYPE_NONE;
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8279 break;
9587
05a56bbe34a1 commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents: 9575
diff changeset
8280 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
8281 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
8282 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
8283 case VAR_UNKNOWN:
10359
66f1b5bf3fa6 commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents: 10277
diff changeset
8284 internal_error("f_type(UNKNOWN)");
9571
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8285 n = -1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8286 break;
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 rettv->vval.v_number = n;
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
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8291 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8292 * "virtcol(string)" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8293 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8294 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8295 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
8296 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8297 colnr_T vcol = 0;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8298 pos_T *fp;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8299 int fnum = curbuf->b_fnum;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8300
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8301 fp = var2fpos(&argvars[0], FALSE, &fnum);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8302 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
8303 && fnum == curbuf->b_fnum)
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 getvvcol(curwin, fp, NULL, NULL, &vcol);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8306 ++vcol;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8307 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8308
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8309 rettv->vval.v_number = vcol;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8310 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8313 * "visualmode()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8314 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8315 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8316 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
8317 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8318 char_u str[2];
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8319
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8320 rettv->v_type = VAR_STRING;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8321 str[0] = curbuf->b_visual_mode_eval;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8322 str[1] = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8323 rettv->vval.v_string = vim_strsave(str);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8324
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8325 /* 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
8326 if (non_zero_arg(&argvars[0]))
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8327 curbuf->b_visual_mode_eval = NUL;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8328 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8329
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8330 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8331 * "wildmenumode()" function
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8332 */
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8333 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8334 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
8335 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8336 #ifdef FEAT_WILDMENU
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8337 if (wild_menu_showing)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8338 rettv->vval.v_number = 1;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8339 #endif
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8340 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8343 * "wordcount()" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8346 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
8347 {
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8348 if (rettv_dict_alloc(rettv) == FAIL)
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8349 return;
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8350 cursor_pos_info(rettv->vval.v_dict);
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8351 }
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 /*
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8354 * "xor(expr, expr)" function
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 static void
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8357 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
8358 {
15211
de63593896b3 patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents: 15209
diff changeset
8359 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
8360 ^ 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
8361 }
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8362
5eaa708ab50d commit https://github.com/vim/vim/commit/73dad1e64cb42842d8259cb1a255a6fa59822f76
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8363 #endif /* FEAT_EVAL */