jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.149

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