comparison src/eval.c @ 2141:e10d3c073449 v7.2.423

updated for version 7.2.423 Problem: Crash when assigning s: to variable. (Yukihiro Nakadaira) Solution: Make ga_scripts contain pointer to scriptvar_T instead of scriptvar_T itself. (Dominique Pelle)
author Bram Moolenaar <bram@zimbu.org>
date Fri, 14 May 2010 12:16:25 +0200
parents 111554354870
children 99b225e0dbc1
comparison
equal deleted inserted replaced
2140:12aba62fa7c6 2141:e10d3c073449
143 { 143 {
144 dictitem_T sv_var; 144 dictitem_T sv_var;
145 dict_T sv_dict; 145 dict_T sv_dict;
146 } scriptvar_T; 146 } scriptvar_T;
147 147
148 static garray_T ga_scripts = {0, 0, sizeof(scriptvar_T), 4, NULL}; 148 static garray_T ga_scripts = {0, 0, sizeof(scriptvar_T *), 4, NULL};
149 #define SCRIPT_SV(id) (((scriptvar_T *)ga_scripts.ga_data)[(id) - 1]) 149 #define SCRIPT_SV(id) (((scriptvar_T **)ga_scripts.ga_data)[(id) - 1])
150 #define SCRIPT_VARS(id) (SCRIPT_SV(id).sv_dict.dv_hashtab) 150 #define SCRIPT_VARS(id) (SCRIPT_SV(id)->sv_dict.dv_hashtab)
151 151
152 static int echo_attr = 0; /* attributes used for ":echo" */ 152 static int echo_attr = 0; /* attributes used for ":echo" */
153 153
154 /* Values for trans_function_name() argument: */ 154 /* Values for trans_function_name() argument: */
155 #define TFN_INT 1 /* internal function name OK */ 155 #define TFN_INT 1 /* internal function name OK */
864 } 864 }
865 hash_clear(&vimvarht); 865 hash_clear(&vimvarht);
866 hash_init(&vimvarht); /* garbage_collect() will access it */ 866 hash_init(&vimvarht); /* garbage_collect() will access it */
867 hash_clear(&compat_hashtab); 867 hash_clear(&compat_hashtab);
868 868
869 free_scriptnames();
870
871 /* global variables */
872 vars_clear(&globvarht);
873
874 /* autoloaded script names */
875 ga_clear_strings(&ga_loaded);
876
869 /* script-local variables */ 877 /* script-local variables */
870 for (i = 1; i <= ga_scripts.ga_len; ++i) 878 for (i = 1; i <= ga_scripts.ga_len; ++i)
879 {
871 vars_clear(&SCRIPT_VARS(i)); 880 vars_clear(&SCRIPT_VARS(i));
881 vim_free(SCRIPT_SV(i));
882 }
872 ga_clear(&ga_scripts); 883 ga_clear(&ga_scripts);
873 free_scriptnames();
874
875 /* global variables */
876 vars_clear(&globvarht);
877
878 /* autoloaded script names */
879 ga_clear_strings(&ga_loaded);
880 884
881 /* unreferenced lists and dicts */ 885 /* unreferenced lists and dicts */
882 (void)garbage_collect(); 886 (void)garbage_collect();
883 887
884 /* functions */ 888 /* functions */
18801 if (*varname == NUL) 18805 if (*varname == NUL)
18802 { 18806 {
18803 /* Must be something like "s:", otherwise "ht" would be NULL. */ 18807 /* Must be something like "s:", otherwise "ht" would be NULL. */
18804 switch (varname[-2]) 18808 switch (varname[-2])
18805 { 18809 {
18806 case 's': return &SCRIPT_SV(current_SID).sv_var; 18810 case 's': return &SCRIPT_SV(current_SID)->sv_var;
18807 case 'g': return &globvars_var; 18811 case 'g': return &globvars_var;
18808 case 'v': return &vimvars_var; 18812 case 'v': return &vimvars_var;
18809 case 'b': return &curbuf->b_bufvar; 18813 case 'b': return &curbuf->b_bufvar;
18810 case 'w': return &curwin->w_winvar; 18814 case 'w': return &curwin->w_winvar;
18811 #ifdef FEAT_WINDOWS 18815 #ifdef FEAT_WINDOWS
18926 for (i = 1; i <= ga_scripts.ga_len; ++i) 18930 for (i = 1; i <= ga_scripts.ga_len; ++i)
18927 { 18931 {
18928 ht = &SCRIPT_VARS(i); 18932 ht = &SCRIPT_VARS(i);
18929 if (ht->ht_mask == HT_INIT_SIZE - 1) 18933 if (ht->ht_mask == HT_INIT_SIZE - 1)
18930 ht->ht_array = ht->ht_smallarray; 18934 ht->ht_array = ht->ht_smallarray;
18931 sv = &SCRIPT_SV(i); 18935 sv = SCRIPT_SV(i);
18932 sv->sv_var.di_tv.vval.v_dict = &sv->sv_dict; 18936 sv->sv_var.di_tv.vval.v_dict = &sv->sv_dict;
18933 } 18937 }
18934 18938
18935 while (ga_scripts.ga_len < id) 18939 while (ga_scripts.ga_len < id)
18936 { 18940 {
18937 sv = &SCRIPT_SV(ga_scripts.ga_len + 1); 18941 sv = SCRIPT_SV(ga_scripts.ga_len + 1) =
18942 (scriptvar_T *)alloc_clear(sizeof(scriptvar_T));
18938 init_var_dict(&sv->sv_dict, &sv->sv_var); 18943 init_var_dict(&sv->sv_dict, &sv->sv_var);
18939 ++ga_scripts.ga_len; 18944 ++ga_scripts.ga_len;
18940 } 18945 }
18941 } 18946 }
18942 } 18947 }
21929 char_u numbuf[NUMBUFLEN]; 21934 char_u numbuf[NUMBUFLEN];
21930 21935
21931 if (find_viminfo_parameter('!') == NULL) 21936 if (find_viminfo_parameter('!') == NULL)
21932 return; 21937 return;
21933 21938
21934 fprintf(fp, _("\n# global variables:\n")); 21939 fputs(_("\n# global variables:\n"), fp);
21935 21940
21936 todo = (int)globvarht.ht_used; 21941 todo = (int)globvarht.ht_used;
21937 for (hi = globvarht.ht_array; todo > 0; ++hi) 21942 for (hi = globvarht.ht_array; todo > 0; ++hi)
21938 { 21943 {
21939 if (!HASHITEM_EMPTY(hi)) 21944 if (!HASHITEM_EMPTY(hi))