|
|
22c937 |
To: vim_dev@googlegroups.com
|
|
|
22c937 |
Subject: Patch 7.4.264
|
|
|
22c937 |
Fcc: outbox
|
|
|
22c937 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
|
22c937 |
Mime-Version: 1.0
|
|
|
22c937 |
Content-Type: text/plain; charset=UTF-8
|
|
|
22c937 |
Content-Transfer-Encoding: 8bit
|
|
|
22c937 |
------------
|
|
|
22c937 |
|
|
|
22c937 |
Patch 7.4.264 (after 7.4.260)
|
|
|
22c937 |
Problem: Can't define a function starting with "g:". Can't assign a
|
|
|
22c937 |
funcref to a buffer-local variable.
|
|
|
22c937 |
Solution: Skip "g:" at the start of a function name. Don't check for colons
|
|
|
22c937 |
when assigning to a variable.
|
|
|
22c937 |
Files: src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok
|
|
|
22c937 |
|
|
|
22c937 |
|
|
|
22c937 |
*** ../vim-7.4.263/src/eval.c 2014-04-23 19:44:26.366774008 +0200
|
|
|
22c937 |
--- src/eval.c 2014-04-23 20:40:16.738693276 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 21583,21589 ****
|
|
|
22c937 |
* Get the function name. There are these situations:
|
|
|
22c937 |
* func normal function name
|
|
|
22c937 |
* "name" == func, "fudi.fd_dict" == NULL
|
|
|
22c937 |
- * s:func script-local function name
|
|
|
22c937 |
* dict.func new dictionary entry
|
|
|
22c937 |
* "name" == NULL, "fudi.fd_dict" set,
|
|
|
22c937 |
* "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
|
|
|
22c937 |
--- 21583,21588 ----
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 21593,21598 ****
|
|
|
22c937 |
--- 21592,21599 ----
|
|
|
22c937 |
* dict.func existing dict entry that's not a Funcref
|
|
|
22c937 |
* "name" == NULL, "fudi.fd_dict" set,
|
|
|
22c937 |
* "fudi.fd_di" set, "fudi.fd_newkey" == NULL
|
|
|
22c937 |
+ * s:func script-local function name
|
|
|
22c937 |
+ * g:func global function name, same as "func"
|
|
|
22c937 |
*/
|
|
|
22c937 |
p = eap->arg;
|
|
|
22c937 |
name = trans_function_name(&p, eap->skip, 0, &fudi);
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 22286,22292 ****
|
|
|
22c937 |
}
|
|
|
22c937 |
else
|
|
|
22c937 |
{
|
|
|
22c937 |
! if (lead == 2) /* skip over "s:" */
|
|
|
22c937 |
lv.ll_name += 2;
|
|
|
22c937 |
len = (int)(end - lv.ll_name);
|
|
|
22c937 |
}
|
|
|
22c937 |
--- 22287,22294 ----
|
|
|
22c937 |
}
|
|
|
22c937 |
else
|
|
|
22c937 |
{
|
|
|
22c937 |
! /* skip over "s:" and "g:" */
|
|
|
22c937 |
! if (lead == 2 || (lv.ll_name[0] == 'g' && lv.ll_name[1] == ':'))
|
|
|
22c937 |
lv.ll_name += 2;
|
|
|
22c937 |
len = (int)(end - lv.ll_name);
|
|
|
22c937 |
}
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 22317,22333 ****
|
|
|
22c937 |
else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len))
|
|
|
22c937 |
{
|
|
|
22c937 |
EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
|
|
|
22c937 |
! lv.ll_name);
|
|
|
22c937 |
goto theend;
|
|
|
22c937 |
}
|
|
|
22c937 |
! if (!skip)
|
|
|
22c937 |
{
|
|
|
22c937 |
char_u *cp = vim_strchr(lv.ll_name, ':');
|
|
|
22c937 |
|
|
|
22c937 |
if (cp != NULL && cp < end)
|
|
|
22c937 |
{
|
|
|
22c937 |
! EMSG2(_("E884: Function name cannot contain a colon: %s"),
|
|
|
22c937 |
! lv.ll_name);
|
|
|
22c937 |
goto theend;
|
|
|
22c937 |
}
|
|
|
22c937 |
}
|
|
|
22c937 |
--- 22319,22334 ----
|
|
|
22c937 |
else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len))
|
|
|
22c937 |
{
|
|
|
22c937 |
EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
|
|
|
22c937 |
! start);
|
|
|
22c937 |
goto theend;
|
|
|
22c937 |
}
|
|
|
22c937 |
! if (!skip && !(flags & TFN_QUIET))
|
|
|
22c937 |
{
|
|
|
22c937 |
char_u *cp = vim_strchr(lv.ll_name, ':');
|
|
|
22c937 |
|
|
|
22c937 |
if (cp != NULL && cp < end)
|
|
|
22c937 |
{
|
|
|
22c937 |
! EMSG2(_("E884: Function name cannot contain a colon: %s"), start);
|
|
|
22c937 |
goto theend;
|
|
|
22c937 |
}
|
|
|
22c937 |
}
|
|
|
22c937 |
*** ../vim-7.4.263/src/testdir/test_eval.in 2014-04-23 17:43:37.362948683 +0200
|
|
|
22c937 |
--- src/testdir/test_eval.in 2014-04-23 20:36:50.494698246 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 144,150 ****
|
|
|
22c937 |
:delcommand AR
|
|
|
22c937 |
:call garbagecollect(1)
|
|
|
22c937 |
:"
|
|
|
22c937 |
! :" function name includes a colon
|
|
|
22c937 |
:try
|
|
|
22c937 |
:func! g:test()
|
|
|
22c937 |
:echo "test"
|
|
|
22c937 |
--- 144,150 ----
|
|
|
22c937 |
:delcommand AR
|
|
|
22c937 |
:call garbagecollect(1)
|
|
|
22c937 |
:"
|
|
|
22c937 |
! :" function name not starting with capital
|
|
|
22c937 |
:try
|
|
|
22c937 |
:func! g:test()
|
|
|
22c937 |
:echo "test"
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 153,158 ****
|
|
|
22c937 |
--- 153,167 ----
|
|
|
22c937 |
:$put =v:exception
|
|
|
22c937 |
:endtry
|
|
|
22c937 |
:"
|
|
|
22c937 |
+ :" function name includes a colon
|
|
|
22c937 |
+ :try
|
|
|
22c937 |
+ :func! b:test()
|
|
|
22c937 |
+ :echo "test"
|
|
|
22c937 |
+ :endfunc
|
|
|
22c937 |
+ :catch
|
|
|
22c937 |
+ :$put =v:exception
|
|
|
22c937 |
+ :endtry
|
|
|
22c937 |
+ :"
|
|
|
22c937 |
:" function name folowed by #
|
|
|
22c937 |
:try
|
|
|
22c937 |
:func! test2() "#
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 162,167 ****
|
|
|
22c937 |
--- 171,183 ----
|
|
|
22c937 |
:$put =v:exception
|
|
|
22c937 |
:endtry
|
|
|
22c937 |
:"
|
|
|
22c937 |
+ :" function name starting with/without "g:", buffer-local funcref.
|
|
|
22c937 |
+ :function! g:Foo()
|
|
|
22c937 |
+ : $put ='called Foo()'
|
|
|
22c937 |
+ :endfunction
|
|
|
22c937 |
+ :let b:my_func = function('Foo')
|
|
|
22c937 |
+ :call b:my_func()
|
|
|
22c937 |
+ :"
|
|
|
22c937 |
:/^start:/+1,$wq! test.out
|
|
|
22c937 |
:" vim: et ts=4 isk-=\: fmr=???,???
|
|
|
22c937 |
:call getchar()
|
|
|
22c937 |
*** ../vim-7.4.263/src/testdir/test_eval.ok 2014-04-23 17:43:37.362948683 +0200
|
|
|
22c937 |
--- src/testdir/test_eval.ok 2014-04-23 20:37:45.526696920 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 336,339 ****
|
|
|
22c937 |
--- 336,341 ----
|
|
|
22c937 |
Executing call setreg(1, ["", "", [], ""])
|
|
|
22c937 |
Vim(call):E730: using List as a String
|
|
|
22c937 |
Vim(function):E128: Function name must start with a capital or "s:": g:test()
|
|
|
22c937 |
+ Vim(function):E128: Function name must start with a capital or "s:": b:test()
|
|
|
22c937 |
Vim(function):E128: Function name must start with a capital or "s:": test2() "#
|
|
|
22c937 |
+ called Foo()
|
|
|
22c937 |
*** ../vim-7.4.263/src/version.c 2014-04-23 19:44:26.370774008 +0200
|
|
|
22c937 |
--- src/version.c 2014-04-23 20:27:17.614712050 +0200
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 736,737 ****
|
|
|
22c937 |
--- 736,739 ----
|
|
|
22c937 |
{ /* Add new patch number below this line */
|
|
|
22c937 |
+ /**/
|
|
|
22c937 |
+ 264,
|
|
|
22c937 |
/**/
|
|
|
22c937 |
|
|
|
22c937 |
--
|
|
|
22c937 |
In order for something to become clean, something else must become dirty;
|
|
|
22c937 |
but you can get everything dirty without getting anything clean.
|
|
|
22c937 |
|
|
|
22c937 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
|
22c937 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
|
22c937 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
|
22c937 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|