Mercurial > vim
comparison src/vim9compile.c @ 19892:5feb426d2ea1 v8.2.0502
patch 8.2.0502: Vim9: some code is not tested
Commit: https://github.com/vim/vim/commit/e8c4abbbd711af8fd3ed85ea69e9ac3d63a0d879
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 2 21:13:25 2020 +0200
patch 8.2.0502: Vim9: some code is not tested
Problem: Vim9: some code is not tested.
Solution: Add more tests. Fix uncovered problems.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 02 Apr 2020 21:15:04 +0200 |
parents | 0d503ba62380 |
children | ea4f8e789627 |
comparison
equal
deleted
inserted
replaced
19891:e1168788aa04 | 19892:5feb426d2ea1 |
---|---|
4093 if (has_call) | 4093 if (has_call) |
4094 { | 4094 { |
4095 *arg = skipwhite(*arg); | 4095 *arg = skipwhite(*arg); |
4096 if (**arg != ')') | 4096 if (**arg != ')') |
4097 return FAIL; | 4097 return FAIL; |
4098 *arg = skipwhite(*arg + 1); | 4098 *arg = *arg + 1; |
4099 | 4099 |
4100 argvars[0] = *tv; | 4100 argvars[0] = *tv; |
4101 argvars[1].v_type = VAR_UNKNOWN; | 4101 argvars[1].v_type = VAR_UNKNOWN; |
4102 tv->v_type = VAR_NUMBER; | 4102 tv->v_type = VAR_NUMBER; |
4103 tv->vval.v_number = 0; | 4103 tv->vval.v_number = 0; |
4267 if (*p == '?') | 4267 if (*p == '?') |
4268 { | 4268 { |
4269 int val = tv2bool(tv); | 4269 int val = tv2bool(tv); |
4270 typval_T tv2; | 4270 typval_T tv2; |
4271 | 4271 |
4272 // require space before and after the ? | |
4272 if (!VIM_ISWHITE(**arg) || !VIM_ISWHITE(p[1])) | 4273 if (!VIM_ISWHITE(**arg) || !VIM_ISWHITE(p[1])) |
4273 return FAIL; | 4274 return FAIL; |
4274 | 4275 |
4275 // evaluate the second expression; any type is accepted | 4276 // evaluate the second expression; any type is accepted |
4276 clear_tv(tv); | 4277 clear_tv(tv); |
4551 | 4552 |
4552 // Reserve a variable to store the loop iteration counter. | 4553 // Reserve a variable to store the loop iteration counter. |
4553 loop_idx = reserve_local(cctx, (char_u *)"", 0, FALSE, &t_number); | 4554 loop_idx = reserve_local(cctx, (char_u *)"", 0, FALSE, &t_number); |
4554 if (loop_idx < 0) | 4555 if (loop_idx < 0) |
4555 { | 4556 { |
4557 // only happens when out of memory | |
4556 drop_scope(cctx); | 4558 drop_scope(cctx); |
4557 return NULL; | 4559 return NULL; |
4558 } | 4560 } |
4559 | 4561 |
4560 // Reserve a variable to store "var" | 4562 // Reserve a variable to store "var" |
4897 else | 4899 else |
4898 { | 4900 { |
4899 char_u *end; | 4901 char_u *end; |
4900 char_u *pat; | 4902 char_u *pat; |
4901 char_u *tofree = NULL; | 4903 char_u *tofree = NULL; |
4904 int dropped = 0; | |
4902 int len; | 4905 int len; |
4903 | 4906 |
4904 // Push v:exception, push {expr} and MATCH | 4907 // Push v:exception, push {expr} and MATCH |
4905 generate_instr_type(cctx, ISN_PUSHEXC, &t_string); | 4908 generate_instr_type(cctx, ISN_PUSHEXC, &t_string); |
4906 | 4909 |
4907 end = skip_regexp(p + 1, *p, TRUE, &tofree); | 4910 end = skip_regexp_ex(p + 1, *p, TRUE, &tofree, &dropped); |
4908 if (*end != *p) | 4911 if (*end != *p) |
4909 { | 4912 { |
4910 semsg(_("E1067: Separator mismatch: %s"), p); | 4913 semsg(_("E1067: Separator mismatch: %s"), p); |
4911 vim_free(tofree); | 4914 vim_free(tofree); |
4912 return FAIL; | 4915 return FAIL; |
4913 } | 4916 } |
4914 if (tofree == NULL) | 4917 if (tofree == NULL) |
4915 len = (int)(end - (p + 1)); | 4918 len = (int)(end - (p + 1)); |
4916 else | 4919 else |
4917 len = (int)(end - (tofree + 1)); | 4920 len = (int)(end - tofree); |
4918 pat = vim_strnsave(p + 1, len); | 4921 pat = vim_strnsave(tofree == NULL ? p + 1 : tofree, len); |
4919 vim_free(tofree); | 4922 vim_free(tofree); |
4920 p += len + 2; | 4923 p += len + 2 + dropped; |
4921 if (pat == NULL) | 4924 if (pat == NULL) |
4922 return FAIL; | 4925 return FAIL; |
4923 if (generate_PUSHS(cctx, pat) == FAIL) | 4926 if (generate_PUSHS(cctx, pat) == FAIL) |
4924 return FAIL; | 4927 return FAIL; |
4925 | 4928 |