summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.264
blob: 06776b880976c6ad94a4e480b7f46e1d62db6dad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
To: vim_dev@googlegroups.com
Subject: Patch 7.4.264
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.264 (after 7.4.260)
Problem:    Can't define a function starting with "g:".  Can't assign a
	    funcref to a buffer-local variable.
Solution:   Skip "g:" at the start of a function name.  Don't check for colons
	    when assigning to a variable.
Files:	    src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok


*** ../vim-7.4.263/src/eval.c	2014-04-23 19:44:26.366774008 +0200
--- src/eval.c	2014-04-23 20:40:16.738693276 +0200
***************
*** 21583,21589 ****
       * Get the function name.  There are these situations:
       * func	    normal function name
       *		    "name" == func, "fudi.fd_dict" == NULL
-      * s:func	    script-local function name
       * dict.func    new dictionary entry
       *		    "name" == NULL, "fudi.fd_dict" set,
       *		    "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
--- 21583,21588 ----
***************
*** 21593,21598 ****
--- 21592,21599 ----
       * dict.func    existing dict entry that's not a Funcref
       *		    "name" == NULL, "fudi.fd_dict" set,
       *		    "fudi.fd_di" set, "fudi.fd_newkey" == NULL
+      * s:func	    script-local function name
+      * g:func	    global function name, same as "func"
       */
      p = eap->arg;
      name = trans_function_name(&p, eap->skip, 0, &fudi);
***************
*** 22286,22292 ****
      }
      else
      {
! 	if (lead == 2)	/* skip over "s:" */
  	    lv.ll_name += 2;
  	len = (int)(end - lv.ll_name);
      }
--- 22287,22294 ----
      }
      else
      {
! 	/* skip over "s:" and "g:" */
! 	if (lead == 2 || (lv.ll_name[0] == 'g' && lv.ll_name[1] == ':'))
  	    lv.ll_name += 2;
  	len = (int)(end - lv.ll_name);
      }
***************
*** 22317,22333 ****
      else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len))
      {
  	EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
! 								  lv.ll_name);
  	goto theend;
      }
!     if (!skip)
      {
  	char_u *cp = vim_strchr(lv.ll_name, ':');
  
  	if (cp != NULL && cp < end)
  	{
! 	    EMSG2(_("E884: Function name cannot contain a colon: %s"),
! 								  lv.ll_name);
  	    goto theend;
  	}
      }
--- 22319,22334 ----
      else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len))
      {
  	EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
! 								       start);
  	goto theend;
      }
!     if (!skip && !(flags & TFN_QUIET))
      {
  	char_u *cp = vim_strchr(lv.ll_name, ':');
  
  	if (cp != NULL && cp < end)
  	{
! 	    EMSG2(_("E884: Function name cannot contain a colon: %s"), start);
  	    goto theend;
  	}
      }
*** ../vim-7.4.263/src/testdir/test_eval.in	2014-04-23 17:43:37.362948683 +0200
--- src/testdir/test_eval.in	2014-04-23 20:36:50.494698246 +0200
***************
*** 144,150 ****
  :delcommand AR
  :call garbagecollect(1)
  :"
! :" function name includes a colon
  :try
  :func! g:test()
  :echo "test"
--- 144,150 ----
  :delcommand AR
  :call garbagecollect(1)
  :"
! :" function name not starting with capital
  :try
  :func! g:test()
  :echo "test"
***************
*** 153,158 ****
--- 153,167 ----
  :$put =v:exception
  :endtry
  :"
+ :" function name includes a colon
+ :try
+ :func! b:test()
+ :echo "test"
+ :endfunc
+ :catch
+ :$put =v:exception
+ :endtry
+ :"
  :" function name folowed by #
  :try
  :func! test2() "#
***************
*** 162,167 ****
--- 171,183 ----
  :$put =v:exception
  :endtry
  :"
+ :" function name starting with/without "g:", buffer-local funcref.
+ :function! g:Foo()
+ :  $put ='called Foo()'
+ :endfunction
+ :let b:my_func = function('Foo')
+ :call b:my_func()
+ :"
  :/^start:/+1,$wq! test.out
  :" vim: et ts=4 isk-=\: fmr=???,???
  :call getchar()
*** ../vim-7.4.263/src/testdir/test_eval.ok	2014-04-23 17:43:37.362948683 +0200
--- src/testdir/test_eval.ok	2014-04-23 20:37:45.526696920 +0200
***************
*** 336,339 ****
--- 336,341 ----
  Executing call setreg(1, ["", "", [], ""])
  Vim(call):E730: using List as a String
  Vim(function):E128: Function name must start with a capital or "s:": g:test()
+ Vim(function):E128: Function name must start with a capital or "s:": b:test()
  Vim(function):E128: Function name must start with a capital or "s:": test2() "#
+ called Foo()
*** ../vim-7.4.263/src/version.c	2014-04-23 19:44:26.370774008 +0200
--- src/version.c	2014-04-23 20:27:17.614712050 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     264,
  /**/

-- 
In order for something to become clean, something else must become dirty;
but you can get everything dirty without getting anything clean.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///