Blame SOURCES/7.4.149

d6ba96
To: vim_dev@googlegroups.com
d6ba96
Subject: Patch 7.4.149
d6ba96
Fcc: outbox
d6ba96
From: Bram Moolenaar <Bram@moolenaar.net>
d6ba96
Mime-Version: 1.0
d6ba96
Content-Type: text/plain; charset=UTF-8
d6ba96
Content-Transfer-Encoding: 8bit
d6ba96
------------
d6ba96
d6ba96
Patch 7.4.149
d6ba96
Problem:    Get E685 error when assigning a function to an autoload variable.
d6ba96
	    (Yukihiro Nakadaira)
d6ba96
Solution:   Instead of having a global no_autoload variable, pass an autoload
d6ba96
	    flag down to where it is used. (ZyX)
d6ba96
Files:	    src/eval.c, src/testdir/test55.in, src/testdir/test55.ok,
d6ba96
	    src/testdir/test60.in, src/testdir/test60.ok,
d6ba96
	    src/testdir/sautest/autoload/footest.vim
d6ba96
d6ba96
d6ba96
*** ../vim-7.4.148/src/eval.c	2014-01-06 06:18:44.000000000 +0100
d6ba96
--- src/eval.c	2014-01-14 15:14:05.000000000 +0100
d6ba96
***************
d6ba96
*** 125,133 ****
d6ba96
   */
d6ba96
  static hashtab_T	compat_hashtab;
d6ba96
  
d6ba96
- /* When using exists() don't auto-load a script. */
d6ba96
- static int		no_autoload = FALSE;
d6ba96
- 
d6ba96
  /*
d6ba96
   * When recursively copying lists and dicts we need to remember which ones we
d6ba96
   * have done to avoid endless recursiveness.  This unique ID is used for that.
d6ba96
--- 125,130 ----
d6ba96
***************
d6ba96
*** 156,161 ****
d6ba96
--- 153,163 ----
d6ba96
  /* Values for trans_function_name() argument: */
d6ba96
  #define TFN_INT		1	/* internal function name OK */
d6ba96
  #define TFN_QUIET	2	/* no error messages */
d6ba96
+ #define TFN_NO_AUTOLOAD	4	/* do not use script autoloading */
d6ba96
+ 
d6ba96
+ /* Values for get_lval() flags argument: */
d6ba96
+ #define GLV_QUIET	TFN_QUIET	/* no error messages */
d6ba96
+ #define GLV_NO_AUTOLOAD	TFN_NO_AUTOLOAD	/* do not use script autoloading */
d6ba96
  
d6ba96
  /*
d6ba96
   * Structure to hold info for a user function.
d6ba96
***************
d6ba96
*** 390,396 ****
d6ba96
  static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg, int *first));
d6ba96
  static char_u *ex_let_one __ARGS((char_u *arg, typval_T *tv, int copy, char_u *endchars, char_u *op));
d6ba96
  static int check_changedtick __ARGS((char_u *arg));
d6ba96
! static char_u *get_lval __ARGS((char_u *name, typval_T *rettv, lval_T *lp, int unlet, int skip, int quiet, int fne_flags));
d6ba96
  static void clear_lval __ARGS((lval_T *lp));
d6ba96
  static void set_var_lval __ARGS((lval_T *lp, char_u *endp, typval_T *rettv, int copy, char_u *op));
d6ba96
  static int tv_op __ARGS((typval_T *tv1, typval_T *tv2, char_u  *op));
d6ba96
--- 392,398 ----
d6ba96
  static char_u *list_arg_vars __ARGS((exarg_T *eap, char_u *arg, int *first));
d6ba96
  static char_u *ex_let_one __ARGS((char_u *arg, typval_T *tv, int copy, char_u *endchars, char_u *op));
d6ba96
  static int check_changedtick __ARGS((char_u *arg));
d6ba96
! static char_u *get_lval __ARGS((char_u *name, typval_T *rettv, lval_T *lp, int unlet, int skip, int flags, int fne_flags));
d6ba96
  static void clear_lval __ARGS((lval_T *lp));
d6ba96
  static void set_var_lval __ARGS((lval_T *lp, char_u *endp, typval_T *rettv, int copy, char_u *op));
d6ba96
  static int tv_op __ARGS((typval_T *tv1, typval_T *tv2, char_u  *op));
d6ba96
***************
d6ba96
*** 770,776 ****
d6ba96
  static char_u * make_expanded_name __ARGS((char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end));
d6ba96
  static int eval_isnamec __ARGS((int c));
d6ba96
  static int eval_isnamec1 __ARGS((int c));
d6ba96
! static int get_var_tv __ARGS((char_u *name, int len, typval_T *rettv, int verbose));
d6ba96
  static int handle_subscript __ARGS((char_u **arg, typval_T *rettv, int evaluate, int verbose));
d6ba96
  static typval_T *alloc_tv __ARGS((void));
d6ba96
  static typval_T *alloc_string_tv __ARGS((char_u *string));
d6ba96
--- 772,778 ----
d6ba96
  static char_u * make_expanded_name __ARGS((char_u *in_start, char_u *expr_start, char_u *expr_end, char_u *in_end));
d6ba96
  static int eval_isnamec __ARGS((int c));
d6ba96
  static int eval_isnamec1 __ARGS((int c));
d6ba96
! static int get_var_tv __ARGS((char_u *name, int len, typval_T *rettv, int verbose, int no_autoload));
d6ba96
  static int handle_subscript __ARGS((char_u **arg, typval_T *rettv, int evaluate, int verbose));
d6ba96
  static typval_T *alloc_tv __ARGS((void));
d6ba96
  static typval_T *alloc_string_tv __ARGS((char_u *string));
d6ba96
***************
d6ba96
*** 781,788 ****
d6ba96
  static char_u *get_tv_string __ARGS((typval_T *varp));
d6ba96
  static char_u *get_tv_string_buf __ARGS((typval_T *varp, char_u *buf));
d6ba96
  static char_u *get_tv_string_buf_chk __ARGS((typval_T *varp, char_u *buf));
d6ba96
! static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp));
d6ba96
! static dictitem_T *find_var_in_ht __ARGS((hashtab_T *ht, int htname, char_u *varname, int writing));
d6ba96
  static hashtab_T *find_var_ht __ARGS((char_u *name, char_u **varname));
d6ba96
  static void vars_clear_ext __ARGS((hashtab_T *ht, int free_val));
d6ba96
  static void delete_var __ARGS((hashtab_T *ht, hashitem_T *hi));
d6ba96
--- 783,790 ----
d6ba96
  static char_u *get_tv_string __ARGS((typval_T *varp));
d6ba96
  static char_u *get_tv_string_buf __ARGS((typval_T *varp, char_u *buf));
d6ba96
  static char_u *get_tv_string_buf_chk __ARGS((typval_T *varp, char_u *buf));
d6ba96
! static dictitem_T *find_var __ARGS((char_u *name, hashtab_T **htp, int no_autoload));
d6ba96
! static dictitem_T *find_var_in_ht __ARGS((hashtab_T *ht, int htname, char_u *varname, int no_autoload));
d6ba96
  static hashtab_T *find_var_ht __ARGS((char_u *name, char_u **varname));
d6ba96
  static void vars_clear_ext __ARGS((hashtab_T *ht, int free_val));
d6ba96
  static void delete_var __ARGS((hashtab_T *ht, hashitem_T *hi));
d6ba96
***************
d6ba96
*** 1059,1065 ****
d6ba96
      ga_init2(&redir_ga, (int)sizeof(char), 500);
d6ba96
  
d6ba96
      /* Parse the variable name (can be a dict or list entry). */
d6ba96
!     redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, FALSE,
d6ba96
  							     FNE_CHECK_START);
d6ba96
      if (redir_endp == NULL || redir_lval->ll_name == NULL || *redir_endp != NUL)
d6ba96
      {
d6ba96
--- 1061,1067 ----
d6ba96
      ga_init2(&redir_ga, (int)sizeof(char), 500);
d6ba96
  
d6ba96
      /* Parse the variable name (can be a dict or list entry). */
d6ba96
!     redir_endp = get_lval(redir_varname, NULL, redir_lval, FALSE, FALSE, 0,
d6ba96
  							     FNE_CHECK_START);
d6ba96
      if (redir_endp == NULL || redir_lval->ll_name == NULL || *redir_endp != NUL)
d6ba96
      {
d6ba96
***************
d6ba96
*** 1150,1156 ****
d6ba96
  	    /* Call get_lval() again, if it's inside a Dict or List it may
d6ba96
  	     * have changed. */
d6ba96
  	    redir_endp = get_lval(redir_varname, NULL, redir_lval,
d6ba96
! 					FALSE, FALSE, FALSE, FNE_CHECK_START);
d6ba96
  	    if (redir_endp != NULL && redir_lval->ll_name != NULL)
d6ba96
  		set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
d6ba96
  	    clear_lval(redir_lval);
d6ba96
--- 1152,1158 ----
d6ba96
  	    /* Call get_lval() again, if it's inside a Dict or List it may
d6ba96
  	     * have changed. */
d6ba96
  	    redir_endp = get_lval(redir_varname, NULL, redir_lval,
d6ba96
! 					FALSE, FALSE, 0, FNE_CHECK_START);
d6ba96
  	    if (redir_endp != NULL && redir_lval->ll_name != NULL)
d6ba96
  		set_var_lval(redir_lval, redir_endp, &tv, FALSE, (char_u *)".");
d6ba96
  	    clear_lval(redir_lval);
d6ba96
***************
d6ba96
*** 2239,2245 ****
d6ba96
  	    {
d6ba96
  		if (tofree != NULL)
d6ba96
  		    name = tofree;
d6ba96
! 		if (get_var_tv(name, len, &tv, TRUE) == FAIL)
d6ba96
  		    error = TRUE;
d6ba96
  		else
d6ba96
  		{
d6ba96
--- 2241,2247 ----
d6ba96
  	    {
d6ba96
  		if (tofree != NULL)
d6ba96
  		    name = tofree;
d6ba96
! 		if (get_var_tv(name, len, &tv, TRUE, FALSE) == FAIL)
d6ba96
  		    error = TRUE;
d6ba96
  		else
d6ba96
  		{
d6ba96
***************
d6ba96
*** 2474,2480 ****
d6ba96
      {
d6ba96
  	lval_T	lv;
d6ba96
  
d6ba96
! 	p = get_lval(arg, tv, &lv, FALSE, FALSE, FALSE, FNE_CHECK_START);
d6ba96
  	if (p != NULL && lv.ll_name != NULL)
d6ba96
  	{
d6ba96
  	    if (endchars != NULL && vim_strchr(endchars, *skipwhite(p)) == NULL)
d6ba96
--- 2476,2482 ----
d6ba96
      {
d6ba96
  	lval_T	lv;
d6ba96
  
d6ba96
! 	p = get_lval(arg, tv, &lv, FALSE, FALSE, 0, FNE_CHECK_START);
d6ba96
  	if (p != NULL && lv.ll_name != NULL)
d6ba96
  	{
d6ba96
  	    if (endchars != NULL && vim_strchr(endchars, *skipwhite(p)) == NULL)
d6ba96
***************
d6ba96
*** 2519,2536 ****
d6ba96
   * "unlet" is TRUE for ":unlet": slightly different behavior when something is
d6ba96
   * wrong; must end in space or cmd separator.
d6ba96
   *
d6ba96
   * Returns a pointer to just after the name, including indexes.
d6ba96
   * When an evaluation error occurs "lp->ll_name" is NULL;
d6ba96
   * Returns NULL for a parsing error.  Still need to free items in "lp"!
d6ba96
   */
d6ba96
      static char_u *
d6ba96
! get_lval(name, rettv, lp, unlet, skip, quiet, fne_flags)
d6ba96
      char_u	*name;
d6ba96
      typval_T	*rettv;
d6ba96
      lval_T	*lp;
d6ba96
      int		unlet;
d6ba96
      int		skip;
d6ba96
!     int		quiet;	    /* don't give error messages */
d6ba96
      int		fne_flags;  /* flags for find_name_end() */
d6ba96
  {
d6ba96
      char_u	*p;
d6ba96
--- 2521,2542 ----
d6ba96
   * "unlet" is TRUE for ":unlet": slightly different behavior when something is
d6ba96
   * wrong; must end in space or cmd separator.
d6ba96
   *
d6ba96
+  * flags:
d6ba96
+  *  GLV_QUIET:       do not give error messages
d6ba96
+  *  GLV_NO_AUTOLOAD: do not use script autoloading
d6ba96
+  *
d6ba96
   * Returns a pointer to just after the name, including indexes.
d6ba96
   * When an evaluation error occurs "lp->ll_name" is NULL;
d6ba96
   * Returns NULL for a parsing error.  Still need to free items in "lp"!
d6ba96
   */
d6ba96
      static char_u *
d6ba96
! get_lval(name, rettv, lp, unlet, skip, flags, fne_flags)
d6ba96
      char_u	*name;
d6ba96
      typval_T	*rettv;
d6ba96
      lval_T	*lp;
d6ba96
      int		unlet;
d6ba96
      int		skip;
d6ba96
!     int		flags;	    /* GLV_ values */
d6ba96
      int		fne_flags;  /* flags for find_name_end() */
d6ba96
  {
d6ba96
      char_u	*p;
d6ba96
***************
d6ba96
*** 2544,2549 ****
d6ba96
--- 2550,2556 ----
d6ba96
      char_u	*key = NULL;
d6ba96
      int		len;
d6ba96
      hashtab_T	*ht;
d6ba96
+     int		quiet = flags & GLV_QUIET;
d6ba96
  
d6ba96
      /* Clear everything in "lp". */
d6ba96
      vim_memset(lp, 0, sizeof(lval_T));
d6ba96
***************
d6ba96
*** 2591,2597 ****
d6ba96
  
d6ba96
      cc = *p;
d6ba96
      *p = NUL;
d6ba96
!     v = find_var(lp->ll_name, &ht;;
d6ba96
      if (v == NULL && !quiet)
d6ba96
  	EMSG2(_(e_undefvar), lp->ll_name);
d6ba96
      *p = cc;
d6ba96
--- 2598,2604 ----
d6ba96
  
d6ba96
      cc = *p;
d6ba96
      *p = NUL;
d6ba96
!     v = find_var(lp->ll_name, &ht, flags & GLV_NO_AUTOLOAD);
d6ba96
      if (v == NULL && !quiet)
d6ba96
  	EMSG2(_(e_undefvar), lp->ll_name);
d6ba96
      *p = cc;
d6ba96
***************
d6ba96
*** 2904,2910 ****
d6ba96
  
d6ba96
  		/* handle +=, -= and .= */
d6ba96
  		if (get_var_tv(lp->ll_name, (int)STRLEN(lp->ll_name),
d6ba96
! 							     &tv, TRUE) == OK)
d6ba96
  		{
d6ba96
  		    if (tv_op(&tv, rettv, op) == OK)
d6ba96
  			set_var(lp->ll_name, &tv, FALSE);
d6ba96
--- 2911,2917 ----
d6ba96
  
d6ba96
  		/* handle +=, -= and .= */
d6ba96
  		if (get_var_tv(lp->ll_name, (int)STRLEN(lp->ll_name),
d6ba96
! 						      &tv, TRUE, FALSE) == OK)
d6ba96
  		{
d6ba96
  		    if (tv_op(&tv, rettv, op) == OK)
d6ba96
  			set_var(lp->ll_name, &tv, FALSE);
d6ba96
***************
d6ba96
*** 3556,3562 ****
d6ba96
      do
d6ba96
      {
d6ba96
  	/* Parse the name and find the end. */
d6ba96
! 	name_end = get_lval(arg, NULL, &lv, TRUE, eap->skip || error, FALSE,
d6ba96
  							     FNE_CHECK_START);
d6ba96
  	if (lv.ll_name == NULL)
d6ba96
  	    error = TRUE;	    /* error but continue parsing */
d6ba96
--- 3563,3569 ----
d6ba96
      do
d6ba96
      {
d6ba96
  	/* Parse the name and find the end. */
d6ba96
! 	name_end = get_lval(arg, NULL, &lv, TRUE, eap->skip || error, 0,
d6ba96
  							     FNE_CHECK_START);
d6ba96
  	if (lv.ll_name == NULL)
d6ba96
  	    error = TRUE;	    /* error but continue parsing */
d6ba96
***************
d6ba96
*** 3709,3715 ****
d6ba96
  	    ret = FAIL;
d6ba96
  	else
d6ba96
  	{
d6ba96
! 	    di = find_var(lp->ll_name, NULL);
d6ba96
  	    if (di == NULL)
d6ba96
  		ret = FAIL;
d6ba96
  	    else
d6ba96
--- 3716,3722 ----
d6ba96
  	    ret = FAIL;
d6ba96
  	else
d6ba96
  	{
d6ba96
! 	    di = find_var(lp->ll_name, NULL, TRUE);
d6ba96
  	    if (di == NULL)
d6ba96
  		ret = FAIL;
d6ba96
  	    else
d6ba96
***************
d6ba96
*** 5179,5185 ****
d6ba96
  		}
d6ba96
  	    }
d6ba96
  	    else if (evaluate)
d6ba96
! 		ret = get_var_tv(s, len, rettv, TRUE);
d6ba96
  	    else
d6ba96
  		ret = OK;
d6ba96
  	}
d6ba96
--- 5186,5192 ----
d6ba96
  		}
d6ba96
  	    }
d6ba96
  	    else if (evaluate)
d6ba96
! 		ret = get_var_tv(s, len, rettv, TRUE, FALSE);
d6ba96
  	    else
d6ba96
  		ret = OK;
d6ba96
  	}
d6ba96
***************
d6ba96
*** 8284,8290 ****
d6ba96
  
d6ba96
      cc = name[*lenp];
d6ba96
      name[*lenp] = NUL;
d6ba96
!     v = find_var(name, NULL);
d6ba96
      name[*lenp] = cc;
d6ba96
      if (v != NULL && v->di_tv.v_type == VAR_FUNC)
d6ba96
      {
d6ba96
--- 8291,8297 ----
d6ba96
  
d6ba96
      cc = name[*lenp];
d6ba96
      name[*lenp] = NUL;
d6ba96
!     v = find_var(name, NULL, FALSE);
d6ba96
      name[*lenp] = cc;
d6ba96
      if (v != NULL && v->di_tv.v_type == VAR_FUNC)
d6ba96
      {
d6ba96
***************
d6ba96
*** 10039,10046 ****
d6ba96
      int		n = FALSE;
d6ba96
      int		len = 0;
d6ba96
  
d6ba96
-     no_autoload = TRUE;
d6ba96
- 
d6ba96
      p = get_tv_string(&argvars[0]);
d6ba96
      if (*p == '$')			/* environment variable */
d6ba96
      {
d6ba96
--- 10046,10051 ----
d6ba96
***************
d6ba96
*** 10091,10097 ****
d6ba96
  	{
d6ba96
  	    if (tofree != NULL)
d6ba96
  		name = tofree;
d6ba96
! 	    n = (get_var_tv(name, len, &tv, FALSE) == OK);
d6ba96
  	    if (n)
d6ba96
  	    {
d6ba96
  		/* handle d.key, l[idx], f(expr) */
d6ba96
--- 10096,10102 ----
d6ba96
  	{
d6ba96
  	    if (tofree != NULL)
d6ba96
  		name = tofree;
d6ba96
! 	    n = (get_var_tv(name, len, &tv, FALSE, TRUE) == OK);
d6ba96
  	    if (n)
d6ba96
  	    {
d6ba96
  		/* handle d.key, l[idx], f(expr) */
d6ba96
***************
d6ba96
*** 10107,10114 ****
d6ba96
      }
d6ba96
  
d6ba96
      rettv->vval.v_number = n;
d6ba96
- 
d6ba96
-     no_autoload = FALSE;
d6ba96
  }
d6ba96
  
d6ba96
  #ifdef FEAT_FLOAT
d6ba96
--- 10112,10117 ----
d6ba96
***************
d6ba96
*** 13344,13351 ****
d6ba96
      dictitem_T	*di;
d6ba96
  
d6ba96
      rettv->vval.v_number = -1;
d6ba96
!     end = get_lval(get_tv_string(&argvars[0]), NULL, &lv, FALSE, FALSE, FALSE,
d6ba96
! 							     FNE_CHECK_START);
d6ba96
      if (end != NULL && lv.ll_name != NULL)
d6ba96
      {
d6ba96
  	if (*end != NUL)
d6ba96
--- 13347,13354 ----
d6ba96
      dictitem_T	*di;
d6ba96
  
d6ba96
      rettv->vval.v_number = -1;
d6ba96
!     end = get_lval(get_tv_string(&argvars[0]), NULL, &lv, FALSE, FALSE,
d6ba96
! 					GLV_NO_AUTOLOAD, FNE_CHECK_START);
d6ba96
      if (end != NULL && lv.ll_name != NULL)
d6ba96
      {
d6ba96
  	if (*end != NUL)
d6ba96
***************
d6ba96
*** 13358,13364 ****
d6ba96
  		    rettv->vval.v_number = 1;	    /* always locked */
d6ba96
  		else
d6ba96
  		{
d6ba96
! 		    di = find_var(lv.ll_name, NULL);
d6ba96
  		    if (di != NULL)
d6ba96
  		    {
d6ba96
  			/* Consider a variable locked when:
d6ba96
--- 13361,13367 ----
d6ba96
  		    rettv->vval.v_number = 1;	    /* always locked */
d6ba96
  		else
d6ba96
  		{
d6ba96
! 		    di = find_var(lv.ll_name, NULL, TRUE);
d6ba96
  		    if (di != NULL)
d6ba96
  		    {
d6ba96
  			/* Consider a variable locked when:
d6ba96
***************
d6ba96
*** 19774,19784 ****
d6ba96
   * Return OK or FAIL.
d6ba96
   */
d6ba96
      static int
d6ba96
! get_var_tv(name, len, rettv, verbose)
d6ba96
      char_u	*name;
d6ba96
      int		len;		/* length of "name" */
d6ba96
      typval_T	*rettv;		/* NULL when only checking existence */
d6ba96
      int		verbose;	/* may give error message */
d6ba96
  {
d6ba96
      int		ret = OK;
d6ba96
      typval_T	*tv = NULL;
d6ba96
--- 19777,19788 ----
d6ba96
   * Return OK or FAIL.
d6ba96
   */
d6ba96
      static int
d6ba96
! get_var_tv(name, len, rettv, verbose, no_autoload)
d6ba96
      char_u	*name;
d6ba96
      int		len;		/* length of "name" */
d6ba96
      typval_T	*rettv;		/* NULL when only checking existence */
d6ba96
      int		verbose;	/* may give error message */
d6ba96
+     int		no_autoload;	/* do not use script autoloading */
d6ba96
  {
d6ba96
      int		ret = OK;
d6ba96
      typval_T	*tv = NULL;
d6ba96
***************
d6ba96
*** 19805,19811 ****
d6ba96
       */
d6ba96
      else
d6ba96
      {
d6ba96
! 	v = find_var(name, NULL);
d6ba96
  	if (v != NULL)
d6ba96
  	    tv = &v->di_tv;
d6ba96
      }
d6ba96
--- 19809,19815 ----
d6ba96
       */
d6ba96
      else
d6ba96
      {
d6ba96
! 	v = find_var(name, NULL, no_autoload);
d6ba96
  	if (v != NULL)
d6ba96
  	    tv = &v->di_tv;
d6ba96
      }
d6ba96
***************
d6ba96
*** 20207,20215 ****
d6ba96
   * hashtab_T used.
d6ba96
   */
d6ba96
      static dictitem_T *
d6ba96
! find_var(name, htp)
d6ba96
      char_u	*name;
d6ba96
      hashtab_T	**htp;
d6ba96
  {
d6ba96
      char_u	*varname;
d6ba96
      hashtab_T	*ht;
d6ba96
--- 20211,20220 ----
d6ba96
   * hashtab_T used.
d6ba96
   */
d6ba96
      static dictitem_T *
d6ba96
! find_var(name, htp, no_autoload)
d6ba96
      char_u	*name;
d6ba96
      hashtab_T	**htp;
d6ba96
+     int		no_autoload;
d6ba96
  {
d6ba96
      char_u	*varname;
d6ba96
      hashtab_T	*ht;
d6ba96
***************
d6ba96
*** 20219,20225 ****
d6ba96
  	*htp = ht;
d6ba96
      if (ht == NULL)
d6ba96
  	return NULL;
d6ba96
!     return find_var_in_ht(ht, *name, varname, htp != NULL);
d6ba96
  }
d6ba96
  
d6ba96
  /*
d6ba96
--- 20224,20230 ----
d6ba96
  	*htp = ht;
d6ba96
      if (ht == NULL)
d6ba96
  	return NULL;
d6ba96
!     return find_var_in_ht(ht, *name, varname, no_autoload || htp != NULL);
d6ba96
  }
d6ba96
  
d6ba96
  /*
d6ba96
***************
d6ba96
*** 20227,20237 ****
d6ba96
   * Returns NULL if not found.
d6ba96
   */
d6ba96
      static dictitem_T *
d6ba96
! find_var_in_ht(ht, htname, varname, writing)
d6ba96
      hashtab_T	*ht;
d6ba96
      int		htname;
d6ba96
      char_u	*varname;
d6ba96
!     int		writing;
d6ba96
  {
d6ba96
      hashitem_T	*hi;
d6ba96
  
d6ba96
--- 20232,20242 ----
d6ba96
   * Returns NULL if not found.
d6ba96
   */
d6ba96
      static dictitem_T *
d6ba96
! find_var_in_ht(ht, htname, varname, no_autoload)
d6ba96
      hashtab_T	*ht;
d6ba96
      int		htname;
d6ba96
      char_u	*varname;
d6ba96
!     int		no_autoload;
d6ba96
  {
d6ba96
      hashitem_T	*hi;
d6ba96
  
d6ba96
***************
d6ba96
*** 20263,20269 ****
d6ba96
  	 * worked find the variable again.  Don't auto-load a script if it was
d6ba96
  	 * loaded already, otherwise it would be loaded every time when
d6ba96
  	 * checking if a function name is a Funcref variable. */
d6ba96
! 	if (ht == &globvarht && !writing)
d6ba96
  	{
d6ba96
  	    /* Note: script_autoload() may make "hi" invalid. It must either
d6ba96
  	     * be obtained again or not used. */
d6ba96
--- 20268,20274 ----
d6ba96
  	 * worked find the variable again.  Don't auto-load a script if it was
d6ba96
  	 * loaded already, otherwise it would be loaded every time when
d6ba96
  	 * checking if a function name is a Funcref variable. */
d6ba96
! 	if (ht == &globvarht && !no_autoload)
d6ba96
  	{
d6ba96
  	    /* Note: script_autoload() may make "hi" invalid. It must either
d6ba96
  	     * be obtained again or not used. */
d6ba96
***************
d6ba96
*** 20343,20349 ****
d6ba96
  {
d6ba96
      dictitem_T	*v;
d6ba96
  
d6ba96
!     v = find_var(name, NULL);
d6ba96
      if (v == NULL)
d6ba96
  	return NULL;
d6ba96
      return get_tv_string(&v->di_tv);
d6ba96
--- 20348,20354 ----
d6ba96
  {
d6ba96
      dictitem_T	*v;
d6ba96
  
d6ba96
!     v = find_var(name, NULL, FALSE);
d6ba96
      if (v == NULL)
d6ba96
  	return NULL;
d6ba96
      return get_tv_string(&v->di_tv);
d6ba96
***************
d6ba96
*** 21672,21678 ****
d6ba96
       */
d6ba96
      if (fudi.fd_dict == NULL)
d6ba96
      {
d6ba96
! 	v = find_var(name, &ht;;
d6ba96
  	if (v != NULL && v->di_tv.v_type == VAR_FUNC)
d6ba96
  	{
d6ba96
  	    emsg_funcname(N_("E707: Function name conflicts with variable: %s"),
d6ba96
--- 21677,21683 ----
d6ba96
       */
d6ba96
      if (fudi.fd_dict == NULL)
d6ba96
      {
d6ba96
! 	v = find_var(name, &ht, FALSE);
d6ba96
  	if (v != NULL && v->di_tv.v_type == VAR_FUNC)
d6ba96
  	{
d6ba96
  	    emsg_funcname(N_("E707: Function name conflicts with variable: %s"),
d6ba96
***************
d6ba96
*** 21830,21837 ****
d6ba96
   * Also handles a Funcref in a List or Dictionary.
d6ba96
   * Returns the function name in allocated memory, or NULL for failure.
d6ba96
   * flags:
d6ba96
!  * TFN_INT:   internal function name OK
d6ba96
!  * TFN_QUIET: be quiet
d6ba96
   * Advances "pp" to just after the function name (if no error).
d6ba96
   */
d6ba96
      static char_u *
d6ba96
--- 21835,21843 ----
d6ba96
   * Also handles a Funcref in a List or Dictionary.
d6ba96
   * Returns the function name in allocated memory, or NULL for failure.
d6ba96
   * flags:
d6ba96
!  * TFN_INT:         internal function name OK
d6ba96
!  * TFN_QUIET:       be quiet
d6ba96
!  * TFN_NO_AUTOLOAD: do not use script autoloading
d6ba96
   * Advances "pp" to just after the function name (if no error).
d6ba96
   */
d6ba96
      static char_u *
d6ba96
***************
d6ba96
*** 21869,21875 ****
d6ba96
      if (lead > 2)
d6ba96
  	start += lead;
d6ba96
  
d6ba96
!     end = get_lval(start, NULL, &lv, FALSE, skip, flags & TFN_QUIET,
d6ba96
  					      lead > 2 ? 0 : FNE_CHECK_START);
d6ba96
      if (end == start)
d6ba96
      {
d6ba96
--- 21875,21882 ----
d6ba96
      if (lead > 2)
d6ba96
  	start += lead;
d6ba96
  
d6ba96
!     /* Note that TFN_ flags use the same values as GLV_ flags. */
d6ba96
!     end = get_lval(start, NULL, &lv, FALSE, skip, flags,
d6ba96
  					      lead > 2 ? 0 : FNE_CHECK_START);
d6ba96
      if (end == start)
d6ba96
      {
d6ba96
***************
d6ba96
*** 22146,22152 ****
d6ba96
      char_u  *p;
d6ba96
      int	    n = FALSE;
d6ba96
  
d6ba96
!     p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET, NULL);
d6ba96
      nm = skipwhite(nm);
d6ba96
  
d6ba96
      /* Only accept "funcname", "funcname ", "funcname (..." and
d6ba96
--- 22153,22160 ----
d6ba96
      char_u  *p;
d6ba96
      int	    n = FALSE;
d6ba96
  
d6ba96
!     p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET|TFN_NO_AUTOLOAD,
d6ba96
! 			    NULL);
d6ba96
      nm = skipwhite(nm);
d6ba96
  
d6ba96
      /* Only accept "funcname", "funcname ", "funcname (..." and
d6ba96
***************
d6ba96
*** 22393,22402 ****
d6ba96
      int		ret = FALSE;
d6ba96
      int		i;
d6ba96
  
d6ba96
-     /* Return quickly when autoload disabled. */
d6ba96
-     if (no_autoload)
d6ba96
- 	return FALSE;
d6ba96
- 
d6ba96
      /* If there is no '#' after name[0] there is no package name. */
d6ba96
      p = vim_strchr(name, AUTOLOAD_CHAR);
d6ba96
      if (p == NULL || p == name)
d6ba96
--- 22401,22406 ----
d6ba96
*** ../vim-7.4.148/src/testdir/test55.in	2013-03-07 14:33:12.000000000 +0100
d6ba96
--- src/testdir/test55.in	2014-01-14 14:48:10.000000000 +0100
d6ba96
***************
d6ba96
*** 282,287 ****
d6ba96
--- 282,294 ----
d6ba96
  :    $put =ps
d6ba96
  :  endfor
d6ba96
  :endfor
d6ba96
+ :" :lockvar/islocked() triggering script autoloading
d6ba96
+ :set rtp+=./sautest
d6ba96
+ :lockvar g:footest#x
d6ba96
+ :unlockvar g:footest#x
d6ba96
+ :$put ='locked g:footest#x:'.islocked('g:footest#x')
d6ba96
+ :$put ='exists g:footest#x:'.exists('g:footest#x')
d6ba96
+ :$put ='g:footest#x: '.g:footest#x
d6ba96
  :"
d6ba96
  :" a:000 function argument
d6ba96
  :" first the tests that should fail
d6ba96
*** ../vim-7.4.148/src/testdir/test55.ok	2012-08-29 16:51:15.000000000 +0200
d6ba96
--- src/testdir/test55.ok	2014-01-14 14:45:14.000000000 +0100
d6ba96
***************
d6ba96
*** 86,91 ****
d6ba96
--- 86,94 ----
d6ba96
  FFpFFpp
d6ba96
  0000-000
d6ba96
  ppppppp
d6ba96
+ locked g:footest#x:-1
d6ba96
+ exists g:footest#x:0
d6ba96
+ g:footest#x: 1
d6ba96
  caught a:000
d6ba96
  caught a:000[0]
d6ba96
  caught a:000[2]
d6ba96
*** ../vim-7.4.148/src/testdir/test60.in	2010-05-15 13:04:10.000000000 +0200
d6ba96
--- src/testdir/test60.in	2014-01-14 14:49:10.000000000 +0100
d6ba96
***************
d6ba96
*** 1,4 ****
d6ba96
! Tests for the exists() function.  vim: set ft=vim :
d6ba96
  
d6ba96
  STARTTEST
d6ba96
  :so small.vim
d6ba96
--- 1,4 ----
d6ba96
! Tests for the exists() function.  vim: set ft=vim ts=8 :
d6ba96
  
d6ba96
  STARTTEST
d6ba96
  :so small.vim
d6ba96
***************
d6ba96
*** 11,18 ****
d6ba96
  endfunction
d6ba96
  :function! TestExists()
d6ba96
      augroup myagroup
d6ba96
! 	autocmd! BufEnter *.my echo 'myfile edited'
d6ba96
      augroup END
d6ba96
  
d6ba96
      let test_cases = []
d6ba96
  
d6ba96
--- 11,20 ----
d6ba96
  endfunction
d6ba96
  :function! TestExists()
d6ba96
      augroup myagroup
d6ba96
! 	autocmd! BufEnter       *.my     echo "myfile edited"
d6ba96
! 	autocmd! FuncUndefined  UndefFun exec "fu UndefFun()\nendfu"
d6ba96
      augroup END
d6ba96
+     set rtp+=./sautest
d6ba96
  
d6ba96
      let test_cases = []
d6ba96
  
d6ba96
***************
d6ba96
*** 95,104 ****
d6ba96
      " Non-existing user defined function
d6ba96
      let test_cases += [['*MyxyzFunc', 0]]
d6ba96
  
d6ba96
      redir! > test.out
d6ba96
  
d6ba96
      for [test_case, result] in test_cases
d6ba96
!       	echo test_case . ": " . result
d6ba96
          call RunTest(test_case, result)
d6ba96
      endfor
d6ba96
  
d6ba96
--- 97,111 ----
d6ba96
      " Non-existing user defined function
d6ba96
      let test_cases += [['*MyxyzFunc', 0]]
d6ba96
  
d6ba96
+     " Function that may be created by FuncUndefined event
d6ba96
+     let test_cases += [['*UndefFun', 0]]
d6ba96
+     " Function that may be created by script autoloading
d6ba96
+     let test_cases += [['*footest#F', 0]]
d6ba96
+ 
d6ba96
      redir! > test.out
d6ba96
  
d6ba96
      for [test_case, result] in test_cases
d6ba96
!         echo test_case . ": " . result
d6ba96
          call RunTest(test_case, result)
d6ba96
      endfor
d6ba96
  
d6ba96
***************
d6ba96
*** 207,212 ****
d6ba96
--- 214,227 ----
d6ba96
  	echo "FAILED"
d6ba96
      endif
d6ba96
  
d6ba96
+     " Non-existing autoload variable that may be autoloaded
d6ba96
+     echo 'footest#x: 0'
d6ba96
+     if !exists('footest#x')
d6ba96
+ 	echo "OK"
d6ba96
+     else
d6ba96
+ 	echo "FAILED"
d6ba96
+     endif
d6ba96
+ 
d6ba96
      " Valid local list
d6ba96
      let local_list = ["blue", "orange"]
d6ba96
      echo 'local_list: 1'
d6ba96
***************
d6ba96
*** 566,571 ****
d6ba96
--- 581,590 ----
d6ba96
  
d6ba96
      call TestFuncArg("arg1", "arg2")
d6ba96
  
d6ba96
+     echo ' g:footest#x =' g:footest#x
d6ba96
+     echo '   footest#F()' footest#F()
d6ba96
+     echo 'UndefFun()' UndefFun()
d6ba96
+ 
d6ba96
      redir END
d6ba96
  endfunction
d6ba96
  :call TestExists()
d6ba96
***************
d6ba96
*** 576,580 ****
d6ba96
--- 595,600 ----
d6ba96
  :set ff=unix
d6ba96
  :w
d6ba96
  :qa!
d6ba96
+ :while getchar(1) | call getchar() | endwhile
d6ba96
  ENDTEST
d6ba96
  
d6ba96
*** ../vim-7.4.148/src/testdir/test60.ok	2010-05-15 13:04:10.000000000 +0200
d6ba96
--- src/testdir/test60.ok	2014-01-14 14:50:50.000000000 +0100
d6ba96
***************
d6ba96
*** 71,76 ****
d6ba96
--- 71,80 ----
d6ba96
  OK
d6ba96
  *MyxyzFunc: 0
d6ba96
  OK
d6ba96
+ *UndefFun: 0
d6ba96
+ OK
d6ba96
+ *footest#F: 0
d6ba96
+ OK
d6ba96
  :edit: 2
d6ba96
  OK
d6ba96
  :edit/a: 0
d6ba96
***************
d6ba96
*** 95,100 ****
d6ba96
--- 99,106 ----
d6ba96
  OK
d6ba96
  local_var: 0
d6ba96
  OK
d6ba96
+ footest#x: 0
d6ba96
+ OK
d6ba96
  local_list: 1
d6ba96
  OK
d6ba96
  local_list[1]: 1
d6ba96
***************
d6ba96
*** 195,197 ****
d6ba96
--- 201,206 ----
d6ba96
  OK
d6ba96
  a:2: 0
d6ba96
  OK
d6ba96
+  g:footest#x = 1
d6ba96
+    footest#F() 0
d6ba96
+ UndefFun() 0
d6ba96
*** ../vim-7.4.148/src/testdir/sautest/autoload/footest.vim	1970-01-01 01:00:00.000000000 +0100
d6ba96
--- src/testdir/sautest/autoload/footest.vim	2014-01-14 14:52:06.000000000 +0100
d6ba96
***************
d6ba96
*** 0 ****
d6ba96
--- 1,5 ----
d6ba96
+ " Autoload script used by test55 and test60
d6ba96
+ let footest#x = 1
d6ba96
+ func footest#F()
d6ba96
+   return 0
d6ba96
+ endfunc
d6ba96
*** ../vim-7.4.148/src/version.c	2014-01-14 13:26:17.000000000 +0100
d6ba96
--- src/version.c	2014-01-14 15:23:36.000000000 +0100
d6ba96
***************
d6ba96
*** 740,741 ****
d6ba96
--- 740,743 ----
d6ba96
  {   /* Add new patch number below this line */
d6ba96
+ /**/
d6ba96
+     149,
d6ba96
  /**/
d6ba96
d6ba96
-- 
d6ba96
hundred-and-one symptoms of being an internet addict:
d6ba96
157. You fum through a magazine, you first check to see if it has a web
d6ba96
     address.
d6ba96
d6ba96
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
d6ba96
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
d6ba96
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
d6ba96
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///