]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
updated for version 7.3.1058 v7.3.1058
authorBram Moolenaar <Bram@vim.org>
Thu, 30 May 2013 10:35:52 +0000 (12:35 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 30 May 2013 10:35:52 +0000 (12:35 +0200)
Problem:    Call of funcref does not succeed in other script.
Solution:   Python patch 17: add get_expanded_name(). (ZyX)

src/eval.c
src/proto/eval.pro
src/version.c

index a07b6d6d4a301db016d7671e903db40a70c94766..8db2a155a2564af10cbf0a8da0448ccdc360e493 100644 (file)
@@ -810,7 +810,6 @@ static int
 # endif
        prof_self_cmp __ARGS((const void *s1, const void *s2));
 #endif
-static int script_autoload __ARGS((char_u *name, int reload));
 static char_u *autoload_name __ARGS((char_u *name));
 static void cat_func_name __ARGS((char_u *buf, ufunc_T *fp));
 static void func_free __ARGS((ufunc_T *fp));
@@ -10946,16 +10945,25 @@ f_function(argvars, rettv)
     typval_T   *rettv;
 {
     char_u     *s;
+    char_u     *name = NULL;
 
     s = get_tv_string(&argvars[0]);
     if (s == NULL || *s == NUL || VIM_ISDIGIT(*s))
        EMSG2(_(e_invarg2), s);
-    /* Don't check an autoload name for existence here. */
-    else if (vim_strchr(s, AUTOLOAD_CHAR) == NULL && !function_exists(s))
+    /* Don't check an autoload name for existence here, but still expand it 
+     * checking for validity */
+    else if ((name = get_expanded_name(s, vim_strchr(s, AUTOLOAD_CHAR) == NULL))
+                                                                       == NULL)
        EMSG2(_("E700: Unknown function: %s"), s);
     else
     {
-       rettv->vval.v_string = vim_strsave(s);
+       if (name == NULL)
+           /* Autoload function, need to copy string */
+           rettv->vval.v_string = vim_strsave(s);
+       else
+           /* Function found by get_expanded_name, string allocated by 
+            * trans_function_name: no need to copy */
+           rettv->vval.v_string = name;
        rettv->v_type = VAR_FUNC;
     }
 }
@@ -21938,6 +21946,33 @@ function_exists(name)
     return n;
 }
 
+    char_u *
+get_expanded_name(name, check)
+    char_u     *name;
+    int                check;
+{
+    char_u     *nm = name;
+    char_u     *p;
+
+    p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET, NULL);
+
+    if (p != NULL && *nm == NUL)
+    {
+       if (!check)
+           return p;
+       else if (builtin_function(p))
+       {
+           if (find_internal_func(p) >= 0)
+               return p;
+       }
+       else
+           if (find_func(p) != NULL)
+               return p;
+    }
+    vim_free(p);
+    return NULL;
+}
+
 /*
  * Return TRUE if "name" looks like a builtin function name: starts with a
  * lower case letter and doesn't contain a ':' or AUTOLOAD_CHAR.
@@ -22146,7 +22181,7 @@ prof_self_cmp(s1, s2)
  * If "name" has a package name try autoloading the script for it.
  * Return TRUE if a package was loaded.
  */
-    static int
+    int
 script_autoload(name, reload)
     char_u     *name;
     int                reload;     /* load script again when already loaded */
index 6d46ebd379056dbe6a3e1286e9050967c0a3985b..7c3f7a13b1103b3af38870cae56452c944d722fb 100644 (file)
@@ -77,6 +77,7 @@ char_u *get_dict_string __ARGS((dict_T *d, char_u *key, int save));
 long get_dict_number __ARGS((dict_T *d, char_u *key));
 char_u *get_function_name __ARGS((expand_T *xp, int idx));
 char_u *get_expr_name __ARGS((expand_T *xp, int idx));
+char_u *get_expanded_name __ARGS((char_u *name, int check));
 int func_call __ARGS((char_u *name, typval_T *args, dict_T *selfdict, typval_T *rettv));
 void mzscheme_call_vim __ARGS((char_u *name, typval_T *args, typval_T *rettv));
 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));
@@ -129,4 +130,5 @@ void last_set_msg __ARGS((scid_T scriptID));
 void ex_oldfiles __ARGS((exarg_T *eap));
 int modify_fname __ARGS((char_u *src, int *usedlen, char_u **fnamep, char_u **bufp, int *fnamelen));
 char_u *do_string_sub __ARGS((char_u *str, char_u *pat, char_u *sub, char_u *flags));
+int script_autoload __ARGS((char_u *name, int reload));
 /* vim: set ft=c : */
index 4d5539a90c9cd9df30f534a6beaaa9c27e518186..33af9b35d248d874aeff31c70f8b56a9d7d404f3 100644 (file)
@@ -728,6 +728,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1058,
 /**/
     1057,
 /**/