Karsten Hopp db5fbe
To: vim-dev@vim.org
Karsten Hopp db5fbe
Subject: Patch 7.2.423
Karsten Hopp db5fbe
Fcc: outbox
Karsten Hopp db5fbe
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp db5fbe
Mime-Version: 1.0
Karsten Hopp db5fbe
Content-Type: text/plain; charset=UTF-8
Karsten Hopp db5fbe
Content-Transfer-Encoding: 8bit
Karsten Hopp db5fbe
------------
Karsten Hopp db5fbe
Karsten Hopp db5fbe
Patch 7.2.423
Karsten Hopp db5fbe
Problem:    Crash when assigning s: to variable. (Yukihiro Nakadaira)
Karsten Hopp db5fbe
Solution:   Make ga_scripts contain pointer to scriptvar_T instead of
Karsten Hopp db5fbe
	    scriptvar_T itself. (Dominique Pelle)
Karsten Hopp db5fbe
Files:	    src/eval.c
Karsten Hopp db5fbe
Karsten Hopp db5fbe
Karsten Hopp db5fbe
*** ../vim-7.2.422/src/eval.c	2010-03-17 19:53:44.000000000 +0100
Karsten Hopp db5fbe
--- src/eval.c	2010-05-14 12:02:16.000000000 +0200
Karsten Hopp db5fbe
***************
Karsten Hopp db5fbe
*** 145,153 ****
Karsten Hopp db5fbe
      dict_T	sv_dict;
Karsten Hopp db5fbe
  } scriptvar_T;
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
! static garray_T	    ga_scripts = {0, 0, sizeof(scriptvar_T), 4, NULL};
Karsten Hopp db5fbe
! #define SCRIPT_SV(id) (((scriptvar_T *)ga_scripts.ga_data)[(id) - 1])
Karsten Hopp db5fbe
! #define SCRIPT_VARS(id) (SCRIPT_SV(id).sv_dict.dv_hashtab)
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
  static int echo_attr = 0;   /* attributes used for ":echo" */
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
--- 145,153 ----
Karsten Hopp db5fbe
      dict_T	sv_dict;
Karsten Hopp db5fbe
  } scriptvar_T;
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
! static garray_T	    ga_scripts = {0, 0, sizeof(scriptvar_T *), 4, NULL};
Karsten Hopp db5fbe
! #define SCRIPT_SV(id) (((scriptvar_T **)ga_scripts.ga_data)[(id) - 1])
Karsten Hopp db5fbe
! #define SCRIPT_VARS(id) (SCRIPT_SV(id)->sv_dict.dv_hashtab)
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
  static int echo_attr = 0;   /* attributes used for ":echo" */
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
***************
Karsten Hopp db5fbe
*** 866,875 ****
Karsten Hopp db5fbe
      hash_init(&vimvarht);  /* garbage_collect() will access it */
Karsten Hopp db5fbe
      hash_clear(&compat_hashtab);
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
-     /* script-local variables */
Karsten Hopp db5fbe
-     for (i = 1; i <= ga_scripts.ga_len; ++i)
Karsten Hopp db5fbe
- 	vars_clear(&SCRIPT_VARS(i));
Karsten Hopp db5fbe
-     ga_clear(&ga_scripts);
Karsten Hopp db5fbe
      free_scriptnames();
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
      /* global variables */
Karsten Hopp db5fbe
--- 866,871 ----
Karsten Hopp db5fbe
***************
Karsten Hopp db5fbe
*** 878,883 ****
Karsten Hopp db5fbe
--- 874,887 ----
Karsten Hopp db5fbe
      /* autoloaded script names */
Karsten Hopp db5fbe
      ga_clear_strings(&ga_loaded);
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
+     /* script-local variables */
Karsten Hopp db5fbe
+     for (i = 1; i <= ga_scripts.ga_len; ++i)
Karsten Hopp db5fbe
+     {
Karsten Hopp db5fbe
+ 	vars_clear(&SCRIPT_VARS(i));
Karsten Hopp db5fbe
+ 	vim_free(SCRIPT_SV(i));
Karsten Hopp db5fbe
+     }
Karsten Hopp db5fbe
+     ga_clear(&ga_scripts);
Karsten Hopp db5fbe
+ 
Karsten Hopp db5fbe
      /* unreferenced lists and dicts */
Karsten Hopp db5fbe
      (void)garbage_collect();
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
***************
Karsten Hopp db5fbe
*** 18803,18809 ****
Karsten Hopp db5fbe
  	/* Must be something like "s:", otherwise "ht" would be NULL. */
Karsten Hopp db5fbe
  	switch (varname[-2])
Karsten Hopp db5fbe
  	{
Karsten Hopp db5fbe
! 	    case 's': return &SCRIPT_SV(current_SID).sv_var;
Karsten Hopp db5fbe
  	    case 'g': return &globvars_var;
Karsten Hopp db5fbe
  	    case 'v': return &vimvars_var;
Karsten Hopp db5fbe
  	    case 'b': return &curbuf->b_bufvar;
Karsten Hopp db5fbe
--- 18807,18813 ----
Karsten Hopp db5fbe
  	/* Must be something like "s:", otherwise "ht" would be NULL. */
Karsten Hopp db5fbe
  	switch (varname[-2])
Karsten Hopp db5fbe
  	{
Karsten Hopp db5fbe
! 	    case 's': return &SCRIPT_SV(current_SID)->sv_var;
Karsten Hopp db5fbe
  	    case 'g': return &globvars_var;
Karsten Hopp db5fbe
  	    case 'v': return &vimvars_var;
Karsten Hopp db5fbe
  	    case 'b': return &curbuf->b_bufvar;
Karsten Hopp db5fbe
***************
Karsten Hopp db5fbe
*** 18928,18940 ****
Karsten Hopp db5fbe
  	    ht = &SCRIPT_VARS(i);
Karsten Hopp db5fbe
  	    if (ht->ht_mask == HT_INIT_SIZE - 1)
Karsten Hopp db5fbe
  		ht->ht_array = ht->ht_smallarray;
Karsten Hopp db5fbe
! 	    sv = &SCRIPT_SV(i);
Karsten Hopp db5fbe
  	    sv->sv_var.di_tv.vval.v_dict = &sv->sv_dict;
Karsten Hopp db5fbe
  	}
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
  	while (ga_scripts.ga_len < id)
Karsten Hopp db5fbe
  	{
Karsten Hopp db5fbe
! 	    sv = &SCRIPT_SV(ga_scripts.ga_len + 1);
Karsten Hopp db5fbe
  	    init_var_dict(&sv->sv_dict, &sv->sv_var);
Karsten Hopp db5fbe
  	    ++ga_scripts.ga_len;
Karsten Hopp db5fbe
  	}
Karsten Hopp db5fbe
--- 18932,18945 ----
Karsten Hopp db5fbe
  	    ht = &SCRIPT_VARS(i);
Karsten Hopp db5fbe
  	    if (ht->ht_mask == HT_INIT_SIZE - 1)
Karsten Hopp db5fbe
  		ht->ht_array = ht->ht_smallarray;
Karsten Hopp db5fbe
! 	    sv = SCRIPT_SV(i);
Karsten Hopp db5fbe
  	    sv->sv_var.di_tv.vval.v_dict = &sv->sv_dict;
Karsten Hopp db5fbe
  	}
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
  	while (ga_scripts.ga_len < id)
Karsten Hopp db5fbe
  	{
Karsten Hopp db5fbe
! 	    sv = SCRIPT_SV(ga_scripts.ga_len + 1) = 
Karsten Hopp db5fbe
! 		(scriptvar_T *)alloc_clear(sizeof(scriptvar_T));
Karsten Hopp db5fbe
  	    init_var_dict(&sv->sv_dict, &sv->sv_var);
Karsten Hopp db5fbe
  	    ++ga_scripts.ga_len;
Karsten Hopp db5fbe
  	}
Karsten Hopp db5fbe
***************
Karsten Hopp db5fbe
*** 21931,21937 ****
Karsten Hopp db5fbe
      if (find_viminfo_parameter('!') == NULL)
Karsten Hopp db5fbe
  	return;
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
!     fprintf(fp, _("\n# global variables:\n"));
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
      todo = (int)globvarht.ht_used;
Karsten Hopp db5fbe
      for (hi = globvarht.ht_array; todo > 0; ++hi)
Karsten Hopp db5fbe
--- 21936,21942 ----
Karsten Hopp db5fbe
      if (find_viminfo_parameter('!') == NULL)
Karsten Hopp db5fbe
  	return;
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
!     fputs(_("\n# global variables:\n"), fp);
Karsten Hopp db5fbe
  
Karsten Hopp db5fbe
      todo = (int)globvarht.ht_used;
Karsten Hopp db5fbe
      for (hi = globvarht.ht_array; todo > 0; ++hi)
Karsten Hopp db5fbe
*** ../vim-7.2.422/src/version.c	2010-05-13 17:46:53.000000000 +0200
Karsten Hopp db5fbe
--- src/version.c	2010-05-14 12:13:19.000000000 +0200
Karsten Hopp db5fbe
***************
Karsten Hopp db5fbe
*** 683,684 ****
Karsten Hopp db5fbe
--- 683,686 ----
Karsten Hopp db5fbe
  {   /* Add new patch number below this line */
Karsten Hopp db5fbe
+ /**/
Karsten Hopp db5fbe
+     423,
Karsten Hopp db5fbe
  /**/
Karsten Hopp db5fbe
Karsten Hopp db5fbe
-- 
Karsten Hopp db5fbe
He who laughs last, thinks slowest.
Karsten Hopp db5fbe
Karsten Hopp db5fbe
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp db5fbe
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp db5fbe
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp db5fbe
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///