comparison src/evalvars.c @ 18477:e93cab5d0f0f v8.1.2233

patch 8.1.2233: cannot get the Vim command line arguments Commit: https://github.com/vim/vim/commit/69bf634858a2a75f2984e42b1e4017bc529a040a Author: Bram Moolenaar <Bram@vim.org> Date: Tue Oct 29 04:16:57 2019 +0100 patch 8.1.2233: cannot get the Vim command line arguments Problem: Cannot get the Vim command line arguments. Solution: Add v:argv. (Dmitri Vereshchagin, closes https://github.com/vim/vim/issues/1322)
author Bram Moolenaar <Bram@vim.org>
date Tue, 29 Oct 2019 04:30:05 +0100
parents 9ea364ccf216
children e47b04b01793
comparison
equal deleted inserted replaced
18476:2eb22798b5a7 18477:e93cab5d0f0f
141 {VV_NAME("termstyleresp", VAR_STRING), VV_RO}, 141 {VV_NAME("termstyleresp", VAR_STRING), VV_RO},
142 {VV_NAME("termblinkresp", VAR_STRING), VV_RO}, 142 {VV_NAME("termblinkresp", VAR_STRING), VV_RO},
143 {VV_NAME("event", VAR_DICT), VV_RO}, 143 {VV_NAME("event", VAR_DICT), VV_RO},
144 {VV_NAME("versionlong", VAR_NUMBER), VV_RO}, 144 {VV_NAME("versionlong", VAR_NUMBER), VV_RO},
145 {VV_NAME("echospace", VAR_NUMBER), VV_RO}, 145 {VV_NAME("echospace", VAR_NUMBER), VV_RO},
146 {VV_NAME("argv", VAR_LIST), VV_RO},
146 }; 147 };
147 148
148 // shorthand 149 // shorthand
149 #define vv_type vv_di.di_tv.v_type 150 #define vv_type vv_di.di_tv.v_type
150 #define vv_nr vv_di.di_tv.vval.v_number 151 #define vv_nr vv_di.di_tv.vval.v_number
2084 dict_set_items_ro(val); 2085 dict_set_items_ro(val);
2085 } 2086 }
2086 } 2087 }
2087 2088
2088 /* 2089 /*
2090 * Set the v:argv list.
2091 */
2092 void
2093 set_argv_var(char **argv, int argc)
2094 {
2095 list_T *l = list_alloc();
2096 int i;
2097
2098 if (l == NULL)
2099 getout(1);
2100 l->lv_lock = VAR_FIXED;
2101 for (i = 0; i < argc; ++i)
2102 {
2103 if (list_append_string(l, (char_u *)argv[i], -1) == FAIL)
2104 getout(1);
2105 l->lv_last->li_tv.v_lock = VAR_FIXED;
2106 }
2107 set_vim_var_list(VV_ARGV, l);
2108 }
2109
2110 /*
2089 * Set v:register if needed. 2111 * Set v:register if needed.
2090 */ 2112 */
2091 void 2113 void
2092 set_reg_var(int c) 2114 set_reg_var(int c)
2093 { 2115 {