Karsten Hopp 262cf9
To: vim_dev@googlegroups.com
Karsten Hopp 262cf9
Subject: Patch 7.4.708
Karsten Hopp 262cf9
Fcc: outbox
Karsten Hopp 262cf9
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 262cf9
Mime-Version: 1.0
Karsten Hopp 262cf9
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 262cf9
Content-Transfer-Encoding: 8bit
Karsten Hopp 262cf9
------------
Karsten Hopp 262cf9
Karsten Hopp 262cf9
Patch 7.4.708
Karsten Hopp 262cf9
Problem:    gettext() is called too often.
Karsten Hopp 262cf9
Solution:   Do not call gettext() for messages until they are actually used.
Karsten Hopp 262cf9
            (idea by Yasuhiro Matsumoto)
Karsten Hopp 262cf9
Files:      src/eval.c
Karsten Hopp 262cf9
Karsten Hopp 262cf9
Karsten Hopp 262cf9
*** ../vim-7.4.707/src/eval.c	2015-04-16 22:51:16.681210896 +0200
Karsten Hopp 262cf9
--- src/eval.c	2015-04-21 16:39:30.342843216 +0200
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 802,812 ****
Karsten Hopp 262cf9
  static void list_one_var __ARGS((dictitem_T *v, char_u *prefix, int *first));
Karsten Hopp 262cf9
  static void list_one_var_a __ARGS((char_u *prefix, char_u *name, int type, char_u *string, int *first));
Karsten Hopp 262cf9
  static void set_var __ARGS((char_u *name, typval_T *varp, int copy));
Karsten Hopp 262cf9
! static int var_check_ro __ARGS((int flags, char_u *name));
Karsten Hopp 262cf9
! static int var_check_fixed __ARGS((int flags, char_u *name));
Karsten Hopp 262cf9
  static int var_check_func_name __ARGS((char_u *name, int new_var));
Karsten Hopp 262cf9
  static int valid_varname __ARGS((char_u *varname));
Karsten Hopp 262cf9
! static int tv_check_lock __ARGS((int lock, char_u *name));
Karsten Hopp 262cf9
  static int item_copy __ARGS((typval_T *from, typval_T *to, int deep, int copyID));
Karsten Hopp 262cf9
  static char_u *find_option_end __ARGS((char_u **arg, int *opt_flags));
Karsten Hopp 262cf9
  static char_u *trans_function_name __ARGS((char_u **pp, int skip, int flags, funcdict_T *fd));
Karsten Hopp 262cf9
--- 802,812 ----
Karsten Hopp 262cf9
  static void list_one_var __ARGS((dictitem_T *v, char_u *prefix, int *first));
Karsten Hopp 262cf9
  static void list_one_var_a __ARGS((char_u *prefix, char_u *name, int type, char_u *string, int *first));
Karsten Hopp 262cf9
  static void set_var __ARGS((char_u *name, typval_T *varp, int copy));
Karsten Hopp 262cf9
! static int var_check_ro __ARGS((int flags, char_u *name, int use_gettext));
Karsten Hopp 262cf9
! static int var_check_fixed __ARGS((int flags, char_u *name, int use_gettext));
Karsten Hopp 262cf9
  static int var_check_func_name __ARGS((char_u *name, int new_var));
Karsten Hopp 262cf9
  static int valid_varname __ARGS((char_u *varname));
Karsten Hopp 262cf9
! static int tv_check_lock __ARGS((int lock, char_u *name, int use_gettext));
Karsten Hopp 262cf9
  static int item_copy __ARGS((typval_T *from, typval_T *to, int deep, int copyID));
Karsten Hopp 262cf9
  static char_u *find_option_end __ARGS((char_u **arg, int *opt_flags));
Karsten Hopp 262cf9
  static char_u *trans_function_name __ARGS((char_u **pp, int skip, int flags, funcdict_T *fd));
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 2808,2814 ****
Karsten Hopp 262cf9
  		break;
Karsten Hopp 262cf9
  	    }
Karsten Hopp 262cf9
  	    /* existing variable, need to check if it can be changed */
Karsten Hopp 262cf9
! 	    else if (var_check_ro(lp->ll_di->di_flags, name))
Karsten Hopp 262cf9
  		return NULL;
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  	    if (len == -1)
Karsten Hopp 262cf9
--- 2808,2814 ----
Karsten Hopp 262cf9
  		break;
Karsten Hopp 262cf9
  	    }
Karsten Hopp 262cf9
  	    /* existing variable, need to check if it can be changed */
Karsten Hopp 262cf9
! 	    else if (var_check_ro(lp->ll_di->di_flags, name, FALSE))
Karsten Hopp 262cf9
  		return NULL;
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  	    if (len == -1)
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 2941,2947 ****
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      else if (tv_check_lock(lp->ll_newkey == NULL
Karsten Hopp 262cf9
  		? lp->ll_tv->v_lock
Karsten Hopp 262cf9
! 		: lp->ll_tv->vval.v_dict->dv_lock, lp->ll_name))
Karsten Hopp 262cf9
  	;
Karsten Hopp 262cf9
      else if (lp->ll_range)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
--- 2941,2947 ----
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      else if (tv_check_lock(lp->ll_newkey == NULL
Karsten Hopp 262cf9
  		? lp->ll_tv->v_lock
Karsten Hopp 262cf9
! 		: lp->ll_tv->vval.v_dict->dv_lock, lp->ll_name, FALSE))
Karsten Hopp 262cf9
  	;
Karsten Hopp 262cf9
      else if (lp->ll_range)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 2953,2959 ****
Karsten Hopp 262cf9
  	 */
Karsten Hopp 262cf9
  	for (ri = rettv->vval.v_list->lv_first; ri != NULL && ll_li != NULL; )
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
! 	    if (tv_check_lock(ll_li->li_tv.v_lock, lp->ll_name))
Karsten Hopp 262cf9
  		return;
Karsten Hopp 262cf9
  	    ri = ri->li_next;
Karsten Hopp 262cf9
  	    if (ri == NULL || (!lp->ll_empty2 && lp->ll_n2 == ll_n1))
Karsten Hopp 262cf9
--- 2953,2959 ----
Karsten Hopp 262cf9
  	 */
Karsten Hopp 262cf9
  	for (ri = rettv->vval.v_list->lv_first; ri != NULL && ll_li != NULL; )
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
! 	    if (tv_check_lock(ll_li->li_tv.v_lock, lp->ll_name, FALSE))
Karsten Hopp 262cf9
  		return;
Karsten Hopp 262cf9
  	    ri = ri->li_next;
Karsten Hopp 262cf9
  	    if (ri == NULL || (!lp->ll_empty2 && lp->ll_n2 == ll_n1))
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 3659,3667 ****
Karsten Hopp 262cf9
  	*name_end = cc;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      else if ((lp->ll_list != NULL
Karsten Hopp 262cf9
! 			  && tv_check_lock(lp->ll_list->lv_lock, lp->ll_name))
Karsten Hopp 262cf9
  	    || (lp->ll_dict != NULL
Karsten Hopp 262cf9
! 			 && tv_check_lock(lp->ll_dict->dv_lock, lp->ll_name)))
Karsten Hopp 262cf9
  	return FAIL;
Karsten Hopp 262cf9
      else if (lp->ll_range)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
--- 3659,3667 ----
Karsten Hopp 262cf9
  	*name_end = cc;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      else if ((lp->ll_list != NULL
Karsten Hopp 262cf9
! 		   && tv_check_lock(lp->ll_list->lv_lock, lp->ll_name, FALSE))
Karsten Hopp 262cf9
  	    || (lp->ll_dict != NULL
Karsten Hopp 262cf9
! 		  && tv_check_lock(lp->ll_dict->dv_lock, lp->ll_name, FALSE)))
Karsten Hopp 262cf9
  	return FAIL;
Karsten Hopp 262cf9
      else if (lp->ll_range)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 3672,3678 ****
Karsten Hopp 262cf9
  	while (ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= ll_n1))
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    li = ll_li->li_next;
Karsten Hopp 262cf9
! 	    if (tv_check_lock(ll_li->li_tv.v_lock, lp->ll_name))
Karsten Hopp 262cf9
  		return FAIL;
Karsten Hopp 262cf9
  	    ll_li = li;
Karsten Hopp 262cf9
  	    ++ll_n1;
Karsten Hopp 262cf9
--- 3672,3678 ----
Karsten Hopp 262cf9
  	while (ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= ll_n1))
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    li = ll_li->li_next;
Karsten Hopp 262cf9
! 	    if (tv_check_lock(ll_li->li_tv.v_lock, lp->ll_name, FALSE))
Karsten Hopp 262cf9
  		return FAIL;
Karsten Hopp 262cf9
  	    ll_li = li;
Karsten Hopp 262cf9
  	    ++ll_n1;
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 3732,3740 ****
Karsten Hopp 262cf9
  	if (!HASHITEM_EMPTY(hi))
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    di = HI2DI(hi);
Karsten Hopp 262cf9
! 	    if (var_check_fixed(di->di_flags, name)
Karsten Hopp 262cf9
! 		    || var_check_ro(di->di_flags, name)
Karsten Hopp 262cf9
! 		    || tv_check_lock(d->dv_lock, name))
Karsten Hopp 262cf9
  		return FAIL;
Karsten Hopp 262cf9
  	    delete_var(ht, hi);
Karsten Hopp 262cf9
  	    return OK;
Karsten Hopp 262cf9
--- 3732,3740 ----
Karsten Hopp 262cf9
  	if (!HASHITEM_EMPTY(hi))
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    di = HI2DI(hi);
Karsten Hopp 262cf9
! 	    if (var_check_fixed(di->di_flags, name, FALSE)
Karsten Hopp 262cf9
! 		    || var_check_ro(di->di_flags, name, FALSE)
Karsten Hopp 262cf9
! 		    || tv_check_lock(d->dv_lock, name, FALSE))
Karsten Hopp 262cf9
  		return FAIL;
Karsten Hopp 262cf9
  	    delete_var(ht, hi);
Karsten Hopp 262cf9
  	    return OK;
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 8937,8943 ****
Karsten Hopp 262cf9
      if (argvars[0].v_type == VAR_LIST)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	if ((l = argvars[0].vval.v_list) != NULL
Karsten Hopp 262cf9
! 		&& !tv_check_lock(l->lv_lock, (char_u *)_("add() argument"))
Karsten Hopp 262cf9
  		&& list_append_tv(l, &argvars[1]) == OK)
Karsten Hopp 262cf9
  	    copy_tv(&argvars[0], rettv);
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
--- 8937,8944 ----
Karsten Hopp 262cf9
      if (argvars[0].v_type == VAR_LIST)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	if ((l = argvars[0].vval.v_list) != NULL
Karsten Hopp 262cf9
! 		&& !tv_check_lock(l->lv_lock,
Karsten Hopp 262cf9
! 					 (char_u *)N_("add() argument"), TRUE)
Karsten Hopp 262cf9
  		&& list_append_tv(l, &argvars[1]) == OK)
Karsten Hopp 262cf9
  	    copy_tv(&argvars[0], rettv);
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 10499,10505 ****
Karsten Hopp 262cf9
      dictitem_T	*di1;
Karsten Hopp 262cf9
      hashitem_T	*hi2;
Karsten Hopp 262cf9
      int		todo;
Karsten Hopp 262cf9
!     char	*arg_errmsg = N_("extend() argument");
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
      todo = (int)d2->dv_hashtab.ht_used;
Karsten Hopp 262cf9
      for (hi2 = d2->dv_hashtab.ht_array; todo > 0; ++hi2)
Karsten Hopp 262cf9
--- 10500,10506 ----
Karsten Hopp 262cf9
      dictitem_T	*di1;
Karsten Hopp 262cf9
      hashitem_T	*hi2;
Karsten Hopp 262cf9
      int		todo;
Karsten Hopp 262cf9
!     char_u	*arg_errmsg = (char_u *)N_("extend() argument");
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
      todo = (int)d2->dv_hashtab.ht_used;
Karsten Hopp 262cf9
      for (hi2 = d2->dv_hashtab.ht_array; todo > 0; ++hi2)
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 10534,10541 ****
Karsten Hopp 262cf9
  	    }
Karsten Hopp 262cf9
  	    else if (*action == 'f' && HI2DI(hi2) != di1)
Karsten Hopp 262cf9
  	    {
Karsten Hopp 262cf9
! 		if (tv_check_lock(di1->di_tv.v_lock, (char_u *)_(arg_errmsg))
Karsten Hopp 262cf9
! 		      || var_check_ro(di1->di_flags, (char_u *)_(arg_errmsg)))
Karsten Hopp 262cf9
  		    break;
Karsten Hopp 262cf9
  		clear_tv(&di1->di_tv);
Karsten Hopp 262cf9
  		copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv);
Karsten Hopp 262cf9
--- 10535,10542 ----
Karsten Hopp 262cf9
  	    }
Karsten Hopp 262cf9
  	    else if (*action == 'f' && HI2DI(hi2) != di1)
Karsten Hopp 262cf9
  	    {
Karsten Hopp 262cf9
! 		if (tv_check_lock(di1->di_tv.v_lock, arg_errmsg, TRUE)
Karsten Hopp 262cf9
! 		      || var_check_ro(di1->di_flags, arg_errmsg, TRUE))
Karsten Hopp 262cf9
  		    break;
Karsten Hopp 262cf9
  		clear_tv(&di1->di_tv);
Karsten Hopp 262cf9
  		copy_tv(&HI2DI(hi2)->di_tv, &di1->di_tv);
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 10553,10559 ****
Karsten Hopp 262cf9
      typval_T	*argvars;
Karsten Hopp 262cf9
      typval_T	*rettv;
Karsten Hopp 262cf9
  {
Karsten Hopp 262cf9
!     char      *arg_errmsg = N_("extend() argument");
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
      if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_LIST)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
--- 10554,10560 ----
Karsten Hopp 262cf9
      typval_T	*argvars;
Karsten Hopp 262cf9
      typval_T	*rettv;
Karsten Hopp 262cf9
  {
Karsten Hopp 262cf9
!     char_u      *arg_errmsg = (char_u *)N_("extend() argument");
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
      if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_LIST)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 10564,10570 ****
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  	l1 = argvars[0].vval.v_list;
Karsten Hopp 262cf9
  	l2 = argvars[1].vval.v_list;
Karsten Hopp 262cf9
! 	if (l1 != NULL && !tv_check_lock(l1->lv_lock, (char_u *)_(arg_errmsg))
Karsten Hopp 262cf9
  		&& l2 != NULL)
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    if (argvars[2].v_type != VAR_UNKNOWN)
Karsten Hopp 262cf9
--- 10565,10571 ----
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  	l1 = argvars[0].vval.v_list;
Karsten Hopp 262cf9
  	l2 = argvars[1].vval.v_list;
Karsten Hopp 262cf9
! 	if (l1 != NULL && !tv_check_lock(l1->lv_lock, arg_errmsg, TRUE)
Karsten Hopp 262cf9
  		&& l2 != NULL)
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    if (argvars[2].v_type != VAR_UNKNOWN)
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 10600,10606 ****
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  	d1 = argvars[0].vval.v_dict;
Karsten Hopp 262cf9
  	d2 = argvars[1].vval.v_dict;
Karsten Hopp 262cf9
! 	if (d1 != NULL && !tv_check_lock(d1->dv_lock, (char_u *)_(arg_errmsg))
Karsten Hopp 262cf9
  		&& d2 != NULL)
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    /* Check the third argument. */
Karsten Hopp 262cf9
--- 10601,10607 ----
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  	d1 = argvars[0].vval.v_dict;
Karsten Hopp 262cf9
  	d2 = argvars[1].vval.v_dict;
Karsten Hopp 262cf9
! 	if (d1 != NULL && !tv_check_lock(d1->dv_lock, arg_errmsg, TRUE)
Karsten Hopp 262cf9
  		&& d2 != NULL)
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    /* Check the third argument. */
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 10819,10825 ****
Karsten Hopp 262cf9
      int		rem;
Karsten Hopp 262cf9
      int		todo;
Karsten Hopp 262cf9
      char_u	*ermsg = (char_u *)(map ? "map()" : "filter()");
Karsten Hopp 262cf9
!     char	*arg_errmsg = (map ? N_("map() argument")
Karsten Hopp 262cf9
  				   : N_("filter() argument"));
Karsten Hopp 262cf9
      int		save_did_emsg;
Karsten Hopp 262cf9
      int		idx = 0;
Karsten Hopp 262cf9
--- 10820,10826 ----
Karsten Hopp 262cf9
      int		rem;
Karsten Hopp 262cf9
      int		todo;
Karsten Hopp 262cf9
      char_u	*ermsg = (char_u *)(map ? "map()" : "filter()");
Karsten Hopp 262cf9
!     char_u	*arg_errmsg = (char_u *)(map ? N_("map() argument")
Karsten Hopp 262cf9
  				   : N_("filter() argument"));
Karsten Hopp 262cf9
      int		save_did_emsg;
Karsten Hopp 262cf9
      int		idx = 0;
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 10827,10839 ****
Karsten Hopp 262cf9
      if (argvars[0].v_type == VAR_LIST)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	if ((l = argvars[0].vval.v_list) == NULL
Karsten Hopp 262cf9
! 	      || (!map && tv_check_lock(l->lv_lock, (char_u *)_(arg_errmsg))))
Karsten Hopp 262cf9
  	    return;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      else if (argvars[0].v_type == VAR_DICT)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	if ((d = argvars[0].vval.v_dict) == NULL
Karsten Hopp 262cf9
! 	      || (!map && tv_check_lock(d->dv_lock, (char_u *)_(arg_errmsg))))
Karsten Hopp 262cf9
  	    return;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      else
Karsten Hopp 262cf9
--- 10828,10840 ----
Karsten Hopp 262cf9
      if (argvars[0].v_type == VAR_LIST)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	if ((l = argvars[0].vval.v_list) == NULL
Karsten Hopp 262cf9
! 	      || (!map && tv_check_lock(l->lv_lock, arg_errmsg, TRUE)))
Karsten Hopp 262cf9
  	    return;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      else if (argvars[0].v_type == VAR_DICT)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	if ((d = argvars[0].vval.v_dict) == NULL
Karsten Hopp 262cf9
! 	      || (!map && tv_check_lock(d->dv_lock, arg_errmsg, TRUE)))
Karsten Hopp 262cf9
  	    return;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      else
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 10873,10882 ****
Karsten Hopp 262cf9
  		    --todo;
Karsten Hopp 262cf9
  		    di = HI2DI(hi);
Karsten Hopp 262cf9
  		    if (map &&
Karsten Hopp 262cf9
! 			    (tv_check_lock(di->di_tv.v_lock,
Karsten Hopp 262cf9
! 						     (char_u *)_(arg_errmsg))
Karsten Hopp 262cf9
! 			    || var_check_ro(di->di_flags,
Karsten Hopp 262cf9
! 						     (char_u *)_(arg_errmsg))))
Karsten Hopp 262cf9
  			break;
Karsten Hopp 262cf9
  		    vimvars[VV_KEY].vv_str = vim_strsave(di->di_key);
Karsten Hopp 262cf9
  		    r = filter_map_one(&di->di_tv, expr, map, &rem;;
Karsten Hopp 262cf9
--- 10874,10881 ----
Karsten Hopp 262cf9
  		    --todo;
Karsten Hopp 262cf9
  		    di = HI2DI(hi);
Karsten Hopp 262cf9
  		    if (map &&
Karsten Hopp 262cf9
! 			    (tv_check_lock(di->di_tv.v_lock, arg_errmsg, TRUE)
Karsten Hopp 262cf9
! 			    || var_check_ro(di->di_flags, arg_errmsg, TRUE)))
Karsten Hopp 262cf9
  			break;
Karsten Hopp 262cf9
  		    vimvars[VV_KEY].vv_str = vim_strsave(di->di_key);
Karsten Hopp 262cf9
  		    r = filter_map_one(&di->di_tv, expr, map, &rem;;
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 10885,10894 ****
Karsten Hopp 262cf9
  			break;
Karsten Hopp 262cf9
  		    if (!map && rem)
Karsten Hopp 262cf9
  		    {
Karsten Hopp 262cf9
! 			if (var_check_fixed(di->di_flags,
Karsten Hopp 262cf9
! 						     (char_u *)_(arg_errmsg))
Karsten Hopp 262cf9
! 			    || var_check_ro(di->di_flags,
Karsten Hopp 262cf9
! 						     (char_u *)_(arg_errmsg)))
Karsten Hopp 262cf9
  			    break;
Karsten Hopp 262cf9
  			dictitem_remove(d, di);
Karsten Hopp 262cf9
  		    }
Karsten Hopp 262cf9
--- 10884,10891 ----
Karsten Hopp 262cf9
  			break;
Karsten Hopp 262cf9
  		    if (!map && rem)
Karsten Hopp 262cf9
  		    {
Karsten Hopp 262cf9
! 			if (var_check_fixed(di->di_flags, arg_errmsg, TRUE)
Karsten Hopp 262cf9
! 			    || var_check_ro(di->di_flags, arg_errmsg, TRUE))
Karsten Hopp 262cf9
  			    break;
Karsten Hopp 262cf9
  			dictitem_remove(d, di);
Karsten Hopp 262cf9
  		    }
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 10902,10909 ****
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  	    for (li = l->lv_first; li != NULL; li = nli)
Karsten Hopp 262cf9
  	    {
Karsten Hopp 262cf9
! 		if (map && tv_check_lock(li->li_tv.v_lock,
Karsten Hopp 262cf9
! 						     (char_u *)_(arg_errmsg)))
Karsten Hopp 262cf9
  		    break;
Karsten Hopp 262cf9
  		nli = li->li_next;
Karsten Hopp 262cf9
  		vimvars[VV_KEY].vv_nr = idx;
Karsten Hopp 262cf9
--- 10899,10905 ----
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  	    for (li = l->lv_first; li != NULL; li = nli)
Karsten Hopp 262cf9
  	    {
Karsten Hopp 262cf9
! 		if (map && tv_check_lock(li->li_tv.v_lock, arg_errmsg, TRUE))
Karsten Hopp 262cf9
  		    break;
Karsten Hopp 262cf9
  		nli = li->li_next;
Karsten Hopp 262cf9
  		vimvars[VV_KEY].vv_nr = idx;
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 13756,13762 ****
Karsten Hopp 262cf9
      if (argvars[0].v_type != VAR_LIST)
Karsten Hopp 262cf9
  	EMSG2(_(e_listarg), "insert()");
Karsten Hopp 262cf9
      else if ((l = argvars[0].vval.v_list) != NULL
Karsten Hopp 262cf9
! 	    && !tv_check_lock(l->lv_lock, (char_u *)_("insert() argument")))
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	if (argvars[2].v_type != VAR_UNKNOWN)
Karsten Hopp 262cf9
  	    before = get_tv_number_chk(&argvars[2], &error);
Karsten Hopp 262cf9
--- 13752,13758 ----
Karsten Hopp 262cf9
      if (argvars[0].v_type != VAR_LIST)
Karsten Hopp 262cf9
  	EMSG2(_(e_listarg), "insert()");
Karsten Hopp 262cf9
      else if ((l = argvars[0].vval.v_list) != NULL
Karsten Hopp 262cf9
! 	    && !tv_check_lock(l->lv_lock, (char_u *)N_("insert() argument"), TRUE))
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	if (argvars[2].v_type != VAR_UNKNOWN)
Karsten Hopp 262cf9
  	    before = get_tv_number_chk(&argvars[2], &error);
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 15837,15850 ****
Karsten Hopp 262cf9
      char_u	*key;
Karsten Hopp 262cf9
      dict_T	*d;
Karsten Hopp 262cf9
      dictitem_T	*di;
Karsten Hopp 262cf9
!     char	*arg_errmsg = N_("remove() argument");
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
      if (argvars[0].v_type == VAR_DICT)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	if (argvars[2].v_type != VAR_UNKNOWN)
Karsten Hopp 262cf9
  	    EMSG2(_(e_toomanyarg), "remove()");
Karsten Hopp 262cf9
  	else if ((d = argvars[0].vval.v_dict) != NULL
Karsten Hopp 262cf9
! 		&& !tv_check_lock(d->dv_lock, (char_u *)_(arg_errmsg)))
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    key = get_tv_string_chk(&argvars[1]);
Karsten Hopp 262cf9
  	    if (key != NULL)
Karsten Hopp 262cf9
--- 15833,15846 ----
Karsten Hopp 262cf9
      char_u	*key;
Karsten Hopp 262cf9
      dict_T	*d;
Karsten Hopp 262cf9
      dictitem_T	*di;
Karsten Hopp 262cf9
!     char_u	*arg_errmsg = (char_u *)N_("remove() argument");
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
      if (argvars[0].v_type == VAR_DICT)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	if (argvars[2].v_type != VAR_UNKNOWN)
Karsten Hopp 262cf9
  	    EMSG2(_(e_toomanyarg), "remove()");
Karsten Hopp 262cf9
  	else if ((d = argvars[0].vval.v_dict) != NULL
Karsten Hopp 262cf9
! 		&& !tv_check_lock(d->dv_lock, arg_errmsg, TRUE))
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    key = get_tv_string_chk(&argvars[1]);
Karsten Hopp 262cf9
  	    if (key != NULL)
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 15852,15860 ****
Karsten Hopp 262cf9
  		di = dict_find(d, key, -1);
Karsten Hopp 262cf9
  		if (di == NULL)
Karsten Hopp 262cf9
  		    EMSG2(_(e_dictkey), key);
Karsten Hopp 262cf9
! 		else if (!var_check_fixed(di->di_flags, (char_u *)_(arg_errmsg))
Karsten Hopp 262cf9
! 			    && !var_check_ro(di->di_flags,
Karsten Hopp 262cf9
! 						     (char_u *)_(arg_errmsg)))
Karsten Hopp 262cf9
  		{
Karsten Hopp 262cf9
  		    *rettv = di->di_tv;
Karsten Hopp 262cf9
  		    init_tv(&di->di_tv);
Karsten Hopp 262cf9
--- 15848,15855 ----
Karsten Hopp 262cf9
  		di = dict_find(d, key, -1);
Karsten Hopp 262cf9
  		if (di == NULL)
Karsten Hopp 262cf9
  		    EMSG2(_(e_dictkey), key);
Karsten Hopp 262cf9
! 		else if (!var_check_fixed(di->di_flags, arg_errmsg, TRUE)
Karsten Hopp 262cf9
! 			    && !var_check_ro(di->di_flags, arg_errmsg, TRUE))
Karsten Hopp 262cf9
  		{
Karsten Hopp 262cf9
  		    *rettv = di->di_tv;
Karsten Hopp 262cf9
  		    init_tv(&di->di_tv);
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 15866,15872 ****
Karsten Hopp 262cf9
      else if (argvars[0].v_type != VAR_LIST)
Karsten Hopp 262cf9
  	EMSG2(_(e_listdictarg), "remove()");
Karsten Hopp 262cf9
      else if ((l = argvars[0].vval.v_list) != NULL
Karsten Hopp 262cf9
! 	    && !tv_check_lock(l->lv_lock, (char_u *)_(arg_errmsg)))
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	int	    error = FALSE;
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
--- 15861,15867 ----
Karsten Hopp 262cf9
      else if (argvars[0].v_type != VAR_LIST)
Karsten Hopp 262cf9
  	EMSG2(_(e_listdictarg), "remove()");
Karsten Hopp 262cf9
      else if ((l = argvars[0].vval.v_list) != NULL
Karsten Hopp 262cf9
! 	    && !tv_check_lock(l->lv_lock, arg_errmsg, TRUE))
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	int	    error = FALSE;
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 16210,16216 ****
Karsten Hopp 262cf9
      if (argvars[0].v_type != VAR_LIST)
Karsten Hopp 262cf9
  	EMSG2(_(e_listarg), "reverse()");
Karsten Hopp 262cf9
      else if ((l = argvars[0].vval.v_list) != NULL
Karsten Hopp 262cf9
! 	    && !tv_check_lock(l->lv_lock, (char_u *)_("reverse() argument")))
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	li = l->lv_last;
Karsten Hopp 262cf9
  	l->lv_first = l->lv_last = NULL;
Karsten Hopp 262cf9
--- 16205,16212 ----
Karsten Hopp 262cf9
      if (argvars[0].v_type != VAR_LIST)
Karsten Hopp 262cf9
  	EMSG2(_(e_listarg), "reverse()");
Karsten Hopp 262cf9
      else if ((l = argvars[0].vval.v_list) != NULL
Karsten Hopp 262cf9
! 	    && !tv_check_lock(l->lv_lock,
Karsten Hopp 262cf9
! 				    (char_u *)N_("reverse() argument"), TRUE))
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	li = l->lv_last;
Karsten Hopp 262cf9
  	l->lv_first = l->lv_last = NULL;
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 17744,17750 ****
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	l = argvars[0].vval.v_list;
Karsten Hopp 262cf9
  	if (l == NULL || tv_check_lock(l->lv_lock,
Karsten Hopp 262cf9
! 	       (char_u *)(sort ? _("sort() argument") : _("uniq() argument"))))
Karsten Hopp 262cf9
  	    return;
Karsten Hopp 262cf9
  	rettv->vval.v_list = l;
Karsten Hopp 262cf9
  	rettv->v_type = VAR_LIST;
Karsten Hopp 262cf9
--- 17740,17747 ----
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	l = argvars[0].vval.v_list;
Karsten Hopp 262cf9
  	if (l == NULL || tv_check_lock(l->lv_lock,
Karsten Hopp 262cf9
! 	     (char_u *)(sort ? N_("sort() argument") : N_("uniq() argument")),
Karsten Hopp 262cf9
! 									TRUE))
Karsten Hopp 262cf9
  	    return;
Karsten Hopp 262cf9
  	rettv->vval.v_list = l;
Karsten Hopp 262cf9
  	rettv->v_type = VAR_LIST;
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 21456,21463 ****
Karsten Hopp 262cf9
      if (v != NULL)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	/* existing variable, need to clear the value */
Karsten Hopp 262cf9
! 	if (var_check_ro(v->di_flags, name)
Karsten Hopp 262cf9
! 				      || tv_check_lock(v->di_tv.v_lock, name))
Karsten Hopp 262cf9
  	    return;
Karsten Hopp 262cf9
  	if (v->di_tv.v_type != tv->v_type
Karsten Hopp 262cf9
  		&& !((v->di_tv.v_type == VAR_STRING
Karsten Hopp 262cf9
--- 21453,21460 ----
Karsten Hopp 262cf9
      if (v != NULL)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	/* existing variable, need to clear the value */
Karsten Hopp 262cf9
! 	if (var_check_ro(v->di_flags, name, FALSE)
Karsten Hopp 262cf9
! 			       || tv_check_lock(v->di_tv.v_lock, name, FALSE))
Karsten Hopp 262cf9
  	    return;
Karsten Hopp 262cf9
  	if (v->di_tv.v_type != tv->v_type
Karsten Hopp 262cf9
  		&& !((v->di_tv.v_type == VAR_STRING
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 21555,21572 ****
Karsten Hopp 262cf9
   * Also give an error message.
Karsten Hopp 262cf9
   */
Karsten Hopp 262cf9
      static int
Karsten Hopp 262cf9
! var_check_ro(flags, name)
Karsten Hopp 262cf9
      int		flags;
Karsten Hopp 262cf9
      char_u	*name;
Karsten Hopp 262cf9
  {
Karsten Hopp 262cf9
      if (flags & DI_FLAGS_RO)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
! 	EMSG2(_(e_readonlyvar), name);
Karsten Hopp 262cf9
  	return TRUE;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      if ((flags & DI_FLAGS_RO_SBX) && sandbox)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
! 	EMSG2(_(e_readonlysbx), name);
Karsten Hopp 262cf9
  	return TRUE;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      return FALSE;
Karsten Hopp 262cf9
--- 21552,21570 ----
Karsten Hopp 262cf9
   * Also give an error message.
Karsten Hopp 262cf9
   */
Karsten Hopp 262cf9
      static int
Karsten Hopp 262cf9
! var_check_ro(flags, name, use_gettext)
Karsten Hopp 262cf9
      int		flags;
Karsten Hopp 262cf9
      char_u	*name;
Karsten Hopp 262cf9
+     int		use_gettext;
Karsten Hopp 262cf9
  {
Karsten Hopp 262cf9
      if (flags & DI_FLAGS_RO)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
! 	EMSG2(_(e_readonlyvar), use_gettext ? (char_u *)_(name) : name);
Karsten Hopp 262cf9
  	return TRUE;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      if ((flags & DI_FLAGS_RO_SBX) && sandbox)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
! 	EMSG2(_(e_readonlysbx), use_gettext ? (char_u *)_(name) : name);
Karsten Hopp 262cf9
  	return TRUE;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      return FALSE;
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 21577,21589 ****
Karsten Hopp 262cf9
   * Also give an error message.
Karsten Hopp 262cf9
   */
Karsten Hopp 262cf9
      static int
Karsten Hopp 262cf9
! var_check_fixed(flags, name)
Karsten Hopp 262cf9
      int		flags;
Karsten Hopp 262cf9
      char_u	*name;
Karsten Hopp 262cf9
  {
Karsten Hopp 262cf9
      if (flags & DI_FLAGS_FIX)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
! 	EMSG2(_("E795: Cannot delete variable %s"), name);
Karsten Hopp 262cf9
  	return TRUE;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      return FALSE;
Karsten Hopp 262cf9
--- 21575,21589 ----
Karsten Hopp 262cf9
   * Also give an error message.
Karsten Hopp 262cf9
   */
Karsten Hopp 262cf9
      static int
Karsten Hopp 262cf9
! var_check_fixed(flags, name, use_gettext)
Karsten Hopp 262cf9
      int		flags;
Karsten Hopp 262cf9
      char_u	*name;
Karsten Hopp 262cf9
+     int		use_gettext;
Karsten Hopp 262cf9
  {
Karsten Hopp 262cf9
      if (flags & DI_FLAGS_FIX)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
! 	EMSG2(_("E795: Cannot delete variable %s"),
Karsten Hopp 262cf9
! 				      use_gettext ? (char_u *)_(name) : name);
Karsten Hopp 262cf9
  	return TRUE;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      return FALSE;
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 21641,21663 ****
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  /*
Karsten Hopp 262cf9
   * Return TRUE if typeval "tv" is set to be locked (immutable).
Karsten Hopp 262cf9
!  * Also give an error message, using "name".
Karsten Hopp 262cf9
   */
Karsten Hopp 262cf9
      static int
Karsten Hopp 262cf9
! tv_check_lock(lock, name)
Karsten Hopp 262cf9
      int		lock;
Karsten Hopp 262cf9
      char_u	*name;
Karsten Hopp 262cf9
  {
Karsten Hopp 262cf9
      if (lock & VAR_LOCKED)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	EMSG2(_("E741: Value is locked: %s"),
Karsten Hopp 262cf9
! 				name == NULL ? (char_u *)_("Unknown") : name);
Karsten Hopp 262cf9
  	return TRUE;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      if (lock & VAR_FIXED)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	EMSG2(_("E742: Cannot change value of %s"),
Karsten Hopp 262cf9
! 				name == NULL ? (char_u *)_("Unknown") : name);
Karsten Hopp 262cf9
  	return TRUE;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      return FALSE;
Karsten Hopp 262cf9
--- 21641,21669 ----
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  /*
Karsten Hopp 262cf9
   * Return TRUE if typeval "tv" is set to be locked (immutable).
Karsten Hopp 262cf9
!  * Also give an error message, using "name" or _("name") when use_gettext is
Karsten Hopp 262cf9
!  * TRUE.
Karsten Hopp 262cf9
   */
Karsten Hopp 262cf9
      static int
Karsten Hopp 262cf9
! tv_check_lock(lock, name, use_gettext)
Karsten Hopp 262cf9
      int		lock;
Karsten Hopp 262cf9
      char_u	*name;
Karsten Hopp 262cf9
+     int		use_gettext;
Karsten Hopp 262cf9
  {
Karsten Hopp 262cf9
      if (lock & VAR_LOCKED)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	EMSG2(_("E741: Value is locked: %s"),
Karsten Hopp 262cf9
! 				name == NULL ? (char_u *)_("Unknown")
Karsten Hopp 262cf9
! 					     : use_gettext ? (char_u *)_(name)
Karsten Hopp 262cf9
! 					     : name);
Karsten Hopp 262cf9
  	return TRUE;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      if (lock & VAR_FIXED)
Karsten Hopp 262cf9
      {
Karsten Hopp 262cf9
  	EMSG2(_("E742: Cannot change value of %s"),
Karsten Hopp 262cf9
! 				name == NULL ? (char_u *)_("Unknown")
Karsten Hopp 262cf9
! 					     : use_gettext ? (char_u *)_(name)
Karsten Hopp 262cf9
! 					     : name);
Karsten Hopp 262cf9
  	return TRUE;
Karsten Hopp 262cf9
      }
Karsten Hopp 262cf9
      return FALSE;
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 22595,22605 ****
Karsten Hopp 262cf9
  	if (fudi.fd_di == NULL)
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    /* Can't add a function to a locked dictionary */
Karsten Hopp 262cf9
! 	    if (tv_check_lock(fudi.fd_dict->dv_lock, eap->arg))
Karsten Hopp 262cf9
  		goto erret;
Karsten Hopp 262cf9
  	}
Karsten Hopp 262cf9
  	    /* Can't change an existing function if it is locked */
Karsten Hopp 262cf9
! 	else if (tv_check_lock(fudi.fd_di->di_tv.v_lock, eap->arg))
Karsten Hopp 262cf9
  	    goto erret;
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  	/* Give the function a sequential number.  Can only be used with a
Karsten Hopp 262cf9
--- 22601,22611 ----
Karsten Hopp 262cf9
  	if (fudi.fd_di == NULL)
Karsten Hopp 262cf9
  	{
Karsten Hopp 262cf9
  	    /* Can't add a function to a locked dictionary */
Karsten Hopp 262cf9
! 	    if (tv_check_lock(fudi.fd_dict->dv_lock, eap->arg, FALSE))
Karsten Hopp 262cf9
  		goto erret;
Karsten Hopp 262cf9
  	}
Karsten Hopp 262cf9
  	    /* Can't change an existing function if it is locked */
Karsten Hopp 262cf9
! 	else if (tv_check_lock(fudi.fd_di->di_tv.v_lock, eap->arg, FALSE))
Karsten Hopp 262cf9
  	    goto erret;
Karsten Hopp 262cf9
  
Karsten Hopp 262cf9
  	/* Give the function a sequential number.  Can only be used with a
Karsten Hopp 262cf9
*** ../vim-7.4.707/src/version.c	2015-04-21 16:12:01.208114832 +0200
Karsten Hopp 262cf9
--- src/version.c	2015-04-21 16:45:02.195367727 +0200
Karsten Hopp 262cf9
***************
Karsten Hopp 262cf9
*** 743,744 ****
Karsten Hopp 262cf9
--- 743,746 ----
Karsten Hopp 262cf9
  {   /* Add new patch number below this line */
Karsten Hopp 262cf9
+ /**/
Karsten Hopp 262cf9
+     708,
Karsten Hopp 262cf9
  /**/
Karsten Hopp 262cf9
Karsten Hopp 262cf9
-- 
Karsten Hopp 262cf9
CRONE:  Who sent you?
Karsten Hopp 262cf9
ARTHUR: The Knights Who Say GNU!
Karsten Hopp 262cf9
CRONE:  Aaaagh!  (she looks around in rear) No!  We have no licenses here.
Karsten Hopp 262cf9
           "Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD
Karsten Hopp 262cf9
Karsten Hopp 262cf9
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 262cf9
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 262cf9
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 262cf9
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///