Karsten Hopp dc0934
To: vim_dev@googlegroups.com
Karsten Hopp dc0934
Subject: Patch 7.3.1058
Karsten Hopp dc0934
Fcc: outbox
Karsten Hopp dc0934
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp dc0934
Mime-Version: 1.0
Karsten Hopp dc0934
Content-Type: text/plain; charset=UTF-8
Karsten Hopp dc0934
Content-Transfer-Encoding: 8bit
Karsten Hopp dc0934
------------
Karsten Hopp dc0934
Karsten Hopp dc0934
Patch 7.3.1058
Karsten Hopp dc0934
Problem:    Call of funcref does not succeed in other script.
Karsten Hopp dc0934
Solution:   Python patch 17: add get_expanded_name(). (ZyX)
Karsten Hopp dc0934
Files:	    src/eval.c, src/proto/eval.pro
Karsten Hopp dc0934
Karsten Hopp dc0934
Karsten Hopp dc0934
*** ../vim-7.3.1057/src/eval.c	2013-05-30 12:14:44.000000000 +0200
Karsten Hopp dc0934
--- src/eval.c	2013-05-30 12:31:55.000000000 +0200
Karsten Hopp dc0934
***************
Karsten Hopp dc0934
*** 810,816 ****
Karsten Hopp dc0934
  # endif
Karsten Hopp dc0934
  	prof_self_cmp __ARGS((const void *s1, const void *s2));
Karsten Hopp dc0934
  #endif
Karsten Hopp dc0934
- static int script_autoload __ARGS((char_u *name, int reload));
Karsten Hopp dc0934
  static char_u *autoload_name __ARGS((char_u *name));
Karsten Hopp dc0934
  static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp));
Karsten Hopp dc0934
  static void func_free __ARGS((ufunc_T *fp));
Karsten Hopp dc0934
--- 810,815 ----
Karsten Hopp dc0934
***************
Karsten Hopp dc0934
*** 10946,10961 ****
Karsten Hopp dc0934
      typval_T	*rettv;
Karsten Hopp dc0934
  {
Karsten Hopp dc0934
      char_u	*s;
Karsten Hopp dc0934
  
Karsten Hopp dc0934
      s = get_tv_string(&argvars[0]);
Karsten Hopp dc0934
      if (s == NULL || *s == NUL || VIM_ISDIGIT(*s))
Karsten Hopp dc0934
  	EMSG2(_(e_invarg2), s);
Karsten Hopp dc0934
!     /* Don't check an autoload name for existence here. */
Karsten Hopp dc0934
!     else if (vim_strchr(s, AUTOLOAD_CHAR) == NULL && !function_exists(s))
Karsten Hopp dc0934
  	EMSG2(_("E700: Unknown function: %s"), s);
Karsten Hopp dc0934
      else
Karsten Hopp dc0934
      {
Karsten Hopp dc0934
! 	rettv->vval.v_string = vim_strsave(s);
Karsten Hopp dc0934
  	rettv->v_type = VAR_FUNC;
Karsten Hopp dc0934
      }
Karsten Hopp dc0934
  }
Karsten Hopp dc0934
--- 10945,10969 ----
Karsten Hopp dc0934
      typval_T	*rettv;
Karsten Hopp dc0934
  {
Karsten Hopp dc0934
      char_u	*s;
Karsten Hopp dc0934
+     char_u	*name = NULL;
Karsten Hopp dc0934
  
Karsten Hopp dc0934
      s = get_tv_string(&argvars[0]);
Karsten Hopp dc0934
      if (s == NULL || *s == NUL || VIM_ISDIGIT(*s))
Karsten Hopp dc0934
  	EMSG2(_(e_invarg2), s);
Karsten Hopp dc0934
!     /* Don't check an autoload name for existence here, but still expand it 
Karsten Hopp dc0934
!      * checking for validity */
Karsten Hopp dc0934
!     else if ((name = get_expanded_name(s, vim_strchr(s, AUTOLOAD_CHAR) == NULL))
Karsten Hopp dc0934
! 									== NULL)
Karsten Hopp dc0934
  	EMSG2(_("E700: Unknown function: %s"), s);
Karsten Hopp dc0934
      else
Karsten Hopp dc0934
      {
Karsten Hopp dc0934
! 	if (name == NULL)
Karsten Hopp dc0934
! 	    /* Autoload function, need to copy string */
Karsten Hopp dc0934
! 	    rettv->vval.v_string = vim_strsave(s);
Karsten Hopp dc0934
! 	else
Karsten Hopp dc0934
! 	    /* Function found by get_expanded_name, string allocated by 
Karsten Hopp dc0934
! 	     * trans_function_name: no need to copy */
Karsten Hopp dc0934
! 	    rettv->vval.v_string = name;
Karsten Hopp dc0934
  	rettv->v_type = VAR_FUNC;
Karsten Hopp dc0934
      }
Karsten Hopp dc0934
  }
Karsten Hopp dc0934
***************
Karsten Hopp dc0934
*** 21938,21943 ****
Karsten Hopp dc0934
--- 21946,21978 ----
Karsten Hopp dc0934
      return n;
Karsten Hopp dc0934
  }
Karsten Hopp dc0934
  
Karsten Hopp dc0934
+     char_u *
Karsten Hopp dc0934
+ get_expanded_name(name, check)
Karsten Hopp dc0934
+     char_u	*name;
Karsten Hopp dc0934
+     int		check;
Karsten Hopp dc0934
+ {
Karsten Hopp dc0934
+     char_u	*nm = name;
Karsten Hopp dc0934
+     char_u	*p;
Karsten Hopp dc0934
+ 
Karsten Hopp dc0934
+     p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET, NULL);
Karsten Hopp dc0934
+ 
Karsten Hopp dc0934
+     if (p != NULL && *nm == NUL)
Karsten Hopp dc0934
+     {
Karsten Hopp dc0934
+ 	if (!check)
Karsten Hopp dc0934
+ 	    return p;
Karsten Hopp dc0934
+ 	else if (builtin_function(p))
Karsten Hopp dc0934
+ 	{
Karsten Hopp dc0934
+ 	    if (find_internal_func(p) >= 0)
Karsten Hopp dc0934
+ 		return p;
Karsten Hopp dc0934
+ 	}
Karsten Hopp dc0934
+ 	else
Karsten Hopp dc0934
+ 	    if (find_func(p) != NULL)
Karsten Hopp dc0934
+ 		return p;
Karsten Hopp dc0934
+     }
Karsten Hopp dc0934
+     vim_free(p);
Karsten Hopp dc0934
+     return NULL;
Karsten Hopp dc0934
+ }
Karsten Hopp dc0934
+ 
Karsten Hopp dc0934
  /*
Karsten Hopp dc0934
   * Return TRUE if "name" looks like a builtin function name: starts with a
Karsten Hopp dc0934
   * lower case letter and doesn't contain a ':' or AUTOLOAD_CHAR.
Karsten Hopp dc0934
***************
Karsten Hopp dc0934
*** 22146,22152 ****
Karsten Hopp dc0934
   * If "name" has a package name try autoloading the script for it.
Karsten Hopp dc0934
   * Return TRUE if a package was loaded.
Karsten Hopp dc0934
   */
Karsten Hopp dc0934
!     static int
Karsten Hopp dc0934
  script_autoload(name, reload)
Karsten Hopp dc0934
      char_u	*name;
Karsten Hopp dc0934
      int		reload;	    /* load script again when already loaded */
Karsten Hopp dc0934
--- 22181,22187 ----
Karsten Hopp dc0934
   * If "name" has a package name try autoloading the script for it.
Karsten Hopp dc0934
   * Return TRUE if a package was loaded.
Karsten Hopp dc0934
   */
Karsten Hopp dc0934
!     int
Karsten Hopp dc0934
  script_autoload(name, reload)
Karsten Hopp dc0934
      char_u	*name;
Karsten Hopp dc0934
      int		reload;	    /* load script again when already loaded */
Karsten Hopp dc0934
*** ../vim-7.3.1057/src/proto/eval.pro	2013-05-30 12:14:44.000000000 +0200
Karsten Hopp dc0934
--- src/proto/eval.pro	2013-05-30 12:31:55.000000000 +0200
Karsten Hopp dc0934
***************
Karsten Hopp dc0934
*** 77,82 ****
Karsten Hopp dc0934
--- 77,83 ----
Karsten Hopp dc0934
  long get_dict_number __ARGS((dict_T *d, char_u *key));
Karsten Hopp dc0934
  char_u *get_function_name __ARGS((expand_T *xp, int idx));
Karsten Hopp dc0934
  char_u *get_expr_name __ARGS((expand_T *xp, int idx));
Karsten Hopp dc0934
+ char_u *get_expanded_name __ARGS((char_u *name, int check));
Karsten Hopp dc0934
  int func_call __ARGS((char_u *name, typval_T *args, dict_T *selfdict, typval_T *rettv));
Karsten Hopp dc0934
  void mzscheme_call_vim __ARGS((char_u *name, typval_T *args, typval_T *rettv));
Karsten Hopp dc0934
  long do_searchpair __ARGS((char_u *spat, char_u *mpat, char_u *epat, int dir, char_u *skip, int flags, pos_T *match_pos, linenr_T lnum_stop, long time_limit));
Karsten Hopp dc0934
***************
Karsten Hopp dc0934
*** 129,132 ****
Karsten Hopp dc0934
--- 130,134 ----
Karsten Hopp dc0934
  void ex_oldfiles __ARGS((exarg_T *eap));
Karsten Hopp dc0934
  int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen));
Karsten Hopp dc0934
  char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags));
Karsten Hopp dc0934
+ int script_autoload __ARGS((char_u *name, int reload));
Karsten Hopp dc0934
  /* vim: set ft=c : */
Karsten Hopp dc0934
*** ../vim-7.3.1057/src/version.c	2013-05-30 12:26:52.000000000 +0200
Karsten Hopp dc0934
--- src/version.c	2013-05-30 12:29:55.000000000 +0200
Karsten Hopp dc0934
***************
Karsten Hopp dc0934
*** 730,731 ****
Karsten Hopp dc0934
--- 730,733 ----
Karsten Hopp dc0934
  {   /* Add new patch number below this line */
Karsten Hopp dc0934
+ /**/
Karsten Hopp dc0934
+     1058,
Karsten Hopp dc0934
  /**/
Karsten Hopp dc0934
Karsten Hopp dc0934
-- 
Karsten Hopp dc0934
How To Keep A Healthy Level Of Insanity:
Karsten Hopp dc0934
1. At lunch time, sit in your parked car with sunglasses on and point
Karsten Hopp dc0934
   a hair dryer at passing cars. See if they slow down.
Karsten Hopp dc0934
Karsten Hopp dc0934
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp dc0934
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp dc0934
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp dc0934
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///