Mercurial > vim
comparison src/eval.c @ 4291:11007e80829c v7.3.895
updated for version 7.3.895
Problem: Valgrind error in test 91. (Issue 128)
Solution: Pass scope name to find_var_in_ht().
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Mon, 15 Apr 2013 13:06:21 +0200 |
parents | dc3efb6d5a08 |
children | aca1886102bd |
comparison
equal
deleted
inserted
replaced
4290:5b2005ff11a3 | 4291:11007e80829c |
---|---|
786 static linenr_T get_tv_lnum_buf __ARGS((typval_T *argvars, buf_T *buf)); | 786 static linenr_T get_tv_lnum_buf __ARGS((typval_T *argvars, buf_T *buf)); |
787 static char_u *get_tv_string __ARGS((typval_T *varp)); | 787 static char_u *get_tv_string __ARGS((typval_T *varp)); |
788 static char_u *get_tv_string_buf __ARGS((typval_T *varp, char_u *buf)); | 788 static char_u *get_tv_string_buf __ARGS((typval_T *varp, char_u *buf)); |
789 static char_u *get_tv_string_buf_chk __ARGS((typval_T *varp, char_u *buf)); | 789 static char_u *get_tv_string_buf_chk __ARGS((typval_T *varp, char_u *buf)); |
790 static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp)); | 790 static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp)); |
791 static dictitem_T *find_var_in_ht __ARGS((hashtab_T *ht, char_u *varname, int writing)); | 791 static dictitem_T *find_var_in_ht __ARGS((hashtab_T *ht, int htname, char_u *varname, int writing)); |
792 static hashtab_T *find_var_ht __ARGS((char_u *name, char_u **varname)); | 792 static hashtab_T *find_var_ht __ARGS((char_u *name, char_u **varname)); |
793 static void vars_clear_ext __ARGS((hashtab_T *ht, int free_val)); | 793 static void vars_clear_ext __ARGS((hashtab_T *ht, int free_val)); |
794 static void delete_var __ARGS((hashtab_T *ht, hashitem_T *hi)); | 794 static void delete_var __ARGS((hashtab_T *ht, hashitem_T *hi)); |
795 static void list_one_var __ARGS((dictitem_T *v, char_u *prefix, int *first)); | 795 static void list_one_var __ARGS((dictitem_T *v, char_u *prefix, int *first)); |
796 static void list_one_var_a __ARGS((char_u *prefix, char_u *name, int type, char_u *string, int *first)); | 796 static void list_one_var_a __ARGS((char_u *prefix, char_u *name, int type, char_u *string, int *first)); |
11148 rettv->v_type = VAR_NUMBER; | 11148 rettv->v_type = VAR_NUMBER; |
11149 rettv->vval.v_number = curbuf->b_changedtick; | 11149 rettv->vval.v_number = curbuf->b_changedtick; |
11150 } | 11150 } |
11151 else | 11151 else |
11152 { | 11152 { |
11153 if (*varname == NUL) | 11153 /* Look up the variable. */ |
11154 /* let getbufvar({nr}, "") return the "b:" dictionary. The | 11154 /* Let getbufvar({nr}, "") return the "b:" dictionary. */ |
11155 * scope prefix before the NUL byte is required by | 11155 v = find_var_in_ht(&curbuf->b_vars->dv_hashtab, |
11156 * find_var_in_ht(). */ | 11156 'b', varname, FALSE); |
11157 varname = (char_u *)"b:" + 2; | |
11158 /* look up the variable */ | |
11159 v = find_var_in_ht(&curbuf->b_vars->dv_hashtab, varname, FALSE); | |
11160 if (v != NULL) | 11157 if (v != NULL) |
11161 copy_tv(&v->di_tv, rettv); | 11158 copy_tv(&v->di_tv, rettv); |
11162 } | 11159 } |
11163 | 11160 |
11164 /* restore previous notion of curbuf */ | 11161 /* restore previous notion of curbuf */ |
11777 varname = get_tv_string_chk(&argvars[1]); | 11774 varname = get_tv_string_chk(&argvars[1]); |
11778 tp = find_tabpage((int)get_tv_number_chk(&argvars[0], NULL)); | 11775 tp = find_tabpage((int)get_tv_number_chk(&argvars[0], NULL)); |
11779 if (tp != NULL && varname != NULL) | 11776 if (tp != NULL && varname != NULL) |
11780 { | 11777 { |
11781 /* look up the variable */ | 11778 /* look up the variable */ |
11782 v = find_var_in_ht(&tp->tp_vars->dv_hashtab, varname, FALSE); | 11779 v = find_var_in_ht(&tp->tp_vars->dv_hashtab, 0, varname, FALSE); |
11783 if (v != NULL) | 11780 if (v != NULL) |
11784 copy_tv(&v->di_tv, rettv); | 11781 copy_tv(&v->di_tv, rettv); |
11785 else if (argvars[2].v_type != VAR_UNKNOWN) | 11782 else if (argvars[2].v_type != VAR_UNKNOWN) |
11786 copy_tv(&argvars[2], rettv); | 11783 copy_tv(&argvars[2], rettv); |
11787 } | 11784 } |
11927 | 11924 |
11928 if (*varname == '&') /* window-local-option */ | 11925 if (*varname == '&') /* window-local-option */ |
11929 get_option_tv(&varname, rettv, 1); | 11926 get_option_tv(&varname, rettv, 1); |
11930 else | 11927 else |
11931 { | 11928 { |
11932 if (*varname == NUL) | 11929 /* Look up the variable. */ |
11933 /* let getwinvar({nr}, "") return the "w:" dictionary. The | 11930 /* Let getwinvar({nr}, "") return the "w:" dictionary. */ |
11934 * scope prefix before the NUL byte is required by | 11931 v = find_var_in_ht(&win->w_vars->dv_hashtab, 'w', varname, FALSE); |
11935 * find_var_in_ht(). */ | |
11936 varname = (char_u *)"w:" + 2; | |
11937 /* look up the variable */ | |
11938 v = find_var_in_ht(&win->w_vars->dv_hashtab, varname, FALSE); | |
11939 if (v != NULL) | 11932 if (v != NULL) |
11940 copy_tv(&v->di_tv, rettv); | 11933 copy_tv(&v->di_tv, rettv); |
11941 } | 11934 } |
11942 | 11935 |
11943 /* restore previous notion of curwin */ | 11936 /* restore previous notion of curwin */ |
20039 ht = find_var_ht(name, &varname); | 20032 ht = find_var_ht(name, &varname); |
20040 if (htp != NULL) | 20033 if (htp != NULL) |
20041 *htp = ht; | 20034 *htp = ht; |
20042 if (ht == NULL) | 20035 if (ht == NULL) |
20043 return NULL; | 20036 return NULL; |
20044 return find_var_in_ht(ht, varname, htp != NULL); | 20037 return find_var_in_ht(ht, *name, varname, htp != NULL); |
20045 } | 20038 } |
20046 | 20039 |
20047 /* | 20040 /* |
20048 * Find variable "varname" in hashtab "ht". | 20041 * Find variable "varname" in hashtab "ht" with name "htname". |
20049 * Returns NULL if not found. | 20042 * Returns NULL if not found. |
20050 */ | 20043 */ |
20051 static dictitem_T * | 20044 static dictitem_T * |
20052 find_var_in_ht(ht, varname, writing) | 20045 find_var_in_ht(ht, htname, varname, writing) |
20053 hashtab_T *ht; | 20046 hashtab_T *ht; |
20047 int htname; | |
20054 char_u *varname; | 20048 char_u *varname; |
20055 int writing; | 20049 int writing; |
20056 { | 20050 { |
20057 hashitem_T *hi; | 20051 hashitem_T *hi; |
20058 | 20052 |
20059 if (*varname == NUL) | 20053 if (*varname == NUL) |
20060 { | 20054 { |
20061 /* Must be something like "s:", otherwise "ht" would be NULL. */ | 20055 /* Must be something like "s:", otherwise "ht" would be NULL. */ |
20062 switch (varname[-2]) | 20056 switch (htname) |
20063 { | 20057 { |
20064 case 's': return &SCRIPT_SV(current_SID)->sv_var; | 20058 case 's': return &SCRIPT_SV(current_SID)->sv_var; |
20065 case 'g': return &globvars_var; | 20059 case 'g': return &globvars_var; |
20066 case 'v': return &vimvars_var; | 20060 case 'v': return &vimvars_var; |
20067 case 'b': return &curbuf->b_bufvar; | 20061 case 'b': return &curbuf->b_bufvar; |
20387 if (ht == NULL || *varname == NUL) | 20381 if (ht == NULL || *varname == NUL) |
20388 { | 20382 { |
20389 EMSG2(_(e_illvar), name); | 20383 EMSG2(_(e_illvar), name); |
20390 return; | 20384 return; |
20391 } | 20385 } |
20392 v = find_var_in_ht(ht, varname, TRUE); | 20386 v = find_var_in_ht(ht, 0, varname, TRUE); |
20393 | 20387 |
20394 if (tv->v_type == VAR_FUNC && var_check_func_name(name, v == NULL)) | 20388 if (tv->v_type == VAR_FUNC && var_check_func_name(name, v == NULL)) |
20395 return; | 20389 return; |
20396 | 20390 |
20397 if (v != NULL) | 20391 if (v != NULL) |