Mercurial > vim
comparison src/eval.c @ 6493:45ff9dd354ea v7.4.574
updated for version 7.4.574
Problem: No error for eval('$').
Solution: Check for empty name. (Yasuhiro Matsumoto)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 14 Jan 2015 17:15:05 +0100 |
parents | 1fd9f1d43660 |
children | b7b3afcae90e |
comparison
equal
deleted
inserted
replaced
6492:1e3ac0aca071 | 6493:45ff9dd354ea |
---|---|
7865 name = *arg; | 7865 name = *arg; |
7866 len = get_env_len(arg); | 7866 len = get_env_len(arg); |
7867 if (evaluate) | 7867 if (evaluate) |
7868 { | 7868 { |
7869 if (len == 0) | 7869 if (len == 0) |
7870 return FAIL; /* can't be an environment variable */ | 7870 return FAIL; /* invalid empty name */ |
7871 | 7871 |
7872 cc = name[len]; | 7872 cc = name[len]; |
7873 name[len] = NUL; | 7873 name[len] = NUL; |
7874 /* first try vim_getenv(), fast for normal environment vars */ | 7874 /* first try vim_getenv(), fast for normal environment vars */ |
7875 string = vim_getenv(name, &mustfree); | 7875 string = vim_getenv(name, &mustfree); |
10115 static void | 10115 static void |
10116 f_eval(argvars, rettv) | 10116 f_eval(argvars, rettv) |
10117 typval_T *argvars; | 10117 typval_T *argvars; |
10118 typval_T *rettv; | 10118 typval_T *rettv; |
10119 { | 10119 { |
10120 char_u *s; | 10120 char_u *s, *p; |
10121 | 10121 |
10122 s = get_tv_string_chk(&argvars[0]); | 10122 s = get_tv_string_chk(&argvars[0]); |
10123 if (s != NULL) | 10123 if (s != NULL) |
10124 s = skipwhite(s); | 10124 s = skipwhite(s); |
10125 | 10125 |
10126 p = s; | |
10126 if (s == NULL || eval1(&s, rettv, TRUE) == FAIL) | 10127 if (s == NULL || eval1(&s, rettv, TRUE) == FAIL) |
10127 { | 10128 { |
10129 if (p != NULL && !aborting()) | |
10130 EMSG2(_(e_invexpr2), p); | |
10131 need_clr_eos = FALSE; | |
10128 rettv->v_type = VAR_NUMBER; | 10132 rettv->v_type = VAR_NUMBER; |
10129 rettv->vval.v_number = 0; | 10133 rettv->vval.v_number = 0; |
10130 } | 10134 } |
10131 else if (*s != NUL) | 10135 else if (*s != NUL) |
10132 EMSG(_(e_trailing)); | 10136 EMSG(_(e_trailing)); |