Srinath Avadhanula wrote:

> If there is a function called Foo(), then it looks like exists('*Foo\W.*')
> evaluates to 1. For example
> 
>     :fun Foo
>     :   return 1
>     :endfun
>     :echo exists('*Foo!asdf')
>     " prints 1
> 
> This happens not just for functions, but variables etc. also. For
> variables, I can work around this by using has_key(g:, varname)
> instead of exists('g:'.varname).

Right, extra text after the function name was ignored.  It's easy to
change, see the patch below.

Would there be scripts that depended on the text being ignored?  Hmm, if
someone has been using exists('function()') then that worked, but won't
work after the patch.

I think I better not change this just before a release.


--- eval.c      27 Apr 2006 21:47:33 -0000      1.171
+++ eval.c      29 Apr 2006 11:26:22 -0000
@@ -19098,18 +19098,19 @@
 function_exists(name)
     char_u *name;
 {
-    char_u  *p = name;
+    char_u  *nm = name;
+    char_u  *p;
     int            n = FALSE;
 
-    p = trans_function_name(&p, FALSE, TFN_INT|TFN_QUIET, NULL);
-    if (p != NULL)
+    p = trans_function_name(&nm, FALSE, TFN_INT|TFN_QUIET, NULL);
+    if (p != NULL && *skipwhite(nm) == NUL)
     {
        if (builtin_function(p))
            n = (find_internal_func(p) >= 0);
        else
            n = (find_func(p) != NULL);
-       vim_free(p);
     }
+    vim_free(p);
     return n;
 }
 

-- 
It is illegal to rob a bank and then shoot at the bank teller with a water
pistol.
                [real standing law in Louisana, United States of America]

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

Reply via email to