comparison src/ex_docmd.c @ 21937:b931df03adcc v8.2.1518

patch 8.2.1518: Vim9: cannot assign to local option Commit: https://github.com/vim/vim/commit/2e80095501238e0c6b702ac7cdfa2e2b763dba28 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 23 19:34:48 2020 +0200 patch 8.2.1518: Vim9: cannot assign to local option Problem: Vim9: cannot assign to local option. Solution: Skip over "&l:" and "&g:". (closes https://github.com/vim/vim/issues/6749)
author Bram Moolenaar <Bram@vim.org>
date Sun, 23 Aug 2020 19:45:03 +0200
parents f19ac9b8b011
children 8350bdbdbb28
comparison
equal deleted inserted replaced
21936:8303e21ae158 21937:b931df03adcc
3241 } 3241 }
3242 *d = NUL; 3242 *d = NUL;
3243 } 3243 }
3244 3244
3245 /* 3245 /*
3246 * If "start" points "&opt", "&l:opt", "&g:opt" or "$ENV" return a pointer to
3247 * the name. Otherwise just return "start".
3248 */
3249 char_u *
3250 skip_option_env_lead(char_u *start)
3251 {
3252 char_u *name = start;
3253
3254 if (*start == '&')
3255 {
3256 if ((start[1] == 'l' || start[1] == 'g') && start[2] == ':')
3257 name += 3;
3258 else
3259 name += 1;
3260 }
3261 else if (*start == '$')
3262 name += 1;
3263 return name;
3264 }
3265
3266 /*
3246 * Find an Ex command by its name, either built-in or user. 3267 * Find an Ex command by its name, either built-in or user.
3247 * Start of the name can be found at eap->cmd. 3268 * Start of the name can be found at eap->cmd.
3248 * Sets eap->cmdidx and returns a pointer to char after the command name. 3269 * Sets eap->cmdidx and returns a pointer to char after the command name.
3249 * "full" is set to TRUE if the whole command name matched. 3270 * "full" is set to TRUE if the whole command name matched.
3250 * 3271 *
3271 * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()" 3292 * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
3272 */ 3293 */
3273 p = eap->cmd; 3294 p = eap->cmd;
3274 if (lookup != NULL) 3295 if (lookup != NULL)
3275 { 3296 {
3276 // Skip over first char for "&opt = val", "$ENV = val" and "@r = val". 3297 char_u *pskip = skip_option_env_lead(eap->cmd);
3277 char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$')
3278 ? eap->cmd + 1 : eap->cmd;
3279 3298
3280 if (vim_strchr((char_u *)"{('[\"@", *p) != NULL 3299 if (vim_strchr((char_u *)"{('[\"@", *p) != NULL
3281 || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)) 3300 || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
3282 { 3301 {
3283 int oplen; 3302 int oplen;