comparison src/vim9compile.c @ 20099:058b41f85bcb v8.2.0605

patch 8.2.0605: Vim9: cannot unlet an environment variable Commit: https://github.com/vim/vim/commit/7bdaea6e0df849cf3dd7eaaf454eb88f637d1884 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Apr 19 18:27:26 2020 +0200 patch 8.2.0605: Vim9: cannot unlet an environment variable Problem: Vim9: cannot unlet an environment variable. Solution: Implement unlet for $VAR.
author Bram Moolenaar <Bram@vim.org>
date Sun, 19 Apr 2020 18:30:04 +0200
parents a64c16ff98b8
children d0a9766167ab
comparison
equal deleted inserted replaced
20098:a901238a18a2 20099:058b41f85bcb
988 988
989 /* 989 /*
990 * Generate an ISN_UNLET instruction. 990 * Generate an ISN_UNLET instruction.
991 */ 991 */
992 static int 992 static int
993 generate_UNLET(cctx_T *cctx, char_u *name, int forceit) 993 generate_UNLET(cctx_T *cctx, isntype_T isn_type, char_u *name, int forceit)
994 { 994 {
995 isn_T *isn; 995 isn_T *isn;
996 996
997 RETURN_OK_IF_SKIP(cctx); 997 RETURN_OK_IF_SKIP(cctx);
998 if ((isn = generate_instr(cctx, ISN_UNLET)) == NULL) 998 if ((isn = generate_instr(cctx, isn_type)) == NULL)
999 return FAIL; 999 return FAIL;
1000 isn->isn_arg.unlet.ul_name = vim_strsave(name); 1000 isn->isn_arg.unlet.ul_name = vim_strsave(name);
1001 isn->isn_arg.unlet.ul_forceit = forceit; 1001 isn->isn_arg.unlet.ul_forceit = forceit;
1002 1002
1003 return OK; 1003 return OK;
4592 int cc = *name_end; 4592 int cc = *name_end;
4593 int ret = OK; 4593 int ret = OK;
4594 4594
4595 // Normal name. Only supports g:, w:, t: and b: namespaces. 4595 // Normal name. Only supports g:, w:, t: and b: namespaces.
4596 *name_end = NUL; 4596 *name_end = NUL;
4597 if (check_vim9_unlet(p) == FAIL) 4597 if (*p == '$')
4598 ret = generate_UNLET(cctx, ISN_UNLETENV, p + 1, eap->forceit);
4599 else if (check_vim9_unlet(p) == FAIL)
4598 ret = FAIL; 4600 ret = FAIL;
4599 else 4601 else
4600 ret = generate_UNLET(cctx, p, eap->forceit); 4602 ret = generate_UNLET(cctx, ISN_UNLET, p, eap->forceit);
4601 4603
4602 *name_end = cc; 4604 *name_end = cc;
4603 return ret; 4605 return ret;
4604 } 4606 }
4605 4607
6361 case ISN_STORES: 6363 case ISN_STORES:
6362 vim_free(isn->isn_arg.loadstore.ls_name); 6364 vim_free(isn->isn_arg.loadstore.ls_name);
6363 break; 6365 break;
6364 6366
6365 case ISN_UNLET: 6367 case ISN_UNLET:
6368 case ISN_UNLETENV:
6366 vim_free(isn->isn_arg.unlet.ul_name); 6369 vim_free(isn->isn_arg.unlet.ul_name);
6367 break; 6370 break;
6368 6371
6369 case ISN_STOREOPT: 6372 case ISN_STOREOPT:
6370 vim_free(isn->isn_arg.storeopt.so_name); 6373 vim_free(isn->isn_arg.storeopt.so_name);