summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.265
blob: da88bdb264ce33fd64128b5450a6b0b41401e621 (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
To: vim_dev@googlegroups.com
Subject: Patch 7.4.265
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.265 (after 7.4.260)
Problem:    Can't call a global function with "g:" in an expression.
Solution:   Skip the "g:" when looking up the function.
Files:	    src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok


*** ../vim-7.4.264/src/eval.c	2014-04-23 20:43:07.290689167 +0200
--- src/eval.c	2014-04-24 17:06:38.884920215 +0200
***************
*** 8485,8517 ****
      /* execute the function if no errors detected and executing */
      if (evaluate && error == ERROR_NONE)
      {
  	rettv->v_type = VAR_NUMBER;	/* default rettv is number zero */
  	rettv->vval.v_number = 0;
  	error = ERROR_UNKNOWN;
  
! 	if (!builtin_function(fname, -1))
  	{
  	    /*
  	     * User defined function.
  	     */
! 	    fp = find_func(fname);
  
  #ifdef FEAT_AUTOCMD
  	    /* Trigger FuncUndefined event, may load the function. */
  	    if (fp == NULL
  		    && apply_autocmds(EVENT_FUNCUNDEFINED,
! 						     fname, fname, TRUE, NULL)
  		    && !aborting())
  	    {
  		/* executed an autocommand, search for the function again */
! 		fp = find_func(fname);
  	    }
  #endif
  	    /* Try loading a package. */
! 	    if (fp == NULL && script_autoload(fname, TRUE) && !aborting())
  	    {
  		/* loaded a package, search for the function again */
! 		fp = find_func(fname);
  	    }
  
  	    if (fp != NULL)
--- 8485,8523 ----
      /* execute the function if no errors detected and executing */
      if (evaluate && error == ERROR_NONE)
      {
+ 	char_u *rfname = fname;
+ 
+ 	/* Ignore "g:" before a function name. */
+ 	if (fname[0] == 'g' && fname[1] == ':')
+ 	    rfname = fname + 2;
+ 
  	rettv->v_type = VAR_NUMBER;	/* default rettv is number zero */
  	rettv->vval.v_number = 0;
  	error = ERROR_UNKNOWN;
  
! 	if (!builtin_function(rfname, -1))
  	{
  	    /*
  	     * User defined function.
  	     */
! 	    fp = find_func(rfname);
  
  #ifdef FEAT_AUTOCMD
  	    /* Trigger FuncUndefined event, may load the function. */
  	    if (fp == NULL
  		    && apply_autocmds(EVENT_FUNCUNDEFINED,
! 						     rfname, rfname, TRUE, NULL)
  		    && !aborting())
  	    {
  		/* executed an autocommand, search for the function again */
! 		fp = find_func(rfname);
  	    }
  #endif
  	    /* Try loading a package. */
! 	    if (fp == NULL && script_autoload(rfname, TRUE) && !aborting())
  	    {
  		/* loaded a package, search for the function again */
! 		fp = find_func(rfname);
  	    }
  
  	    if (fp != NULL)
*** ../vim-7.4.264/src/testdir/test_eval.in	2014-04-23 20:43:07.290689167 +0200
--- src/testdir/test_eval.in	2014-04-24 17:07:57.108918330 +0200
***************
*** 172,182 ****
  :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=???,???
--- 172,184 ----
  :endtry
  :"
  :" function name starting with/without "g:", buffer-local funcref.
! :function! g:Foo(n)
! :  $put ='called Foo(' . a:n . ')'
  :endfunction
  :let b:my_func = function('Foo')
! :call b:my_func(1)
! :echo g:Foo(2)
! :echo Foo(3)
  :"
  :/^start:/+1,$wq! test.out
  :" vim: et ts=4 isk-=\: fmr=???,???
*** ../vim-7.4.264/src/testdir/test_eval.ok	2014-04-23 20:43:07.290689167 +0200
--- src/testdir/test_eval.ok	2014-04-24 16:54:36.856937613 +0200
***************
*** 338,341 ****
  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()
--- 338,343 ----
  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(1)
! called Foo(2)
! called Foo(3)
*** ../vim-7.4.264/src/version.c	2014-04-23 20:43:07.290689167 +0200
--- src/version.c	2014-04-24 16:56:24.520935019 +0200
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     265,
  /**/

-- 
The sooner you fall behind, the more time you'll have to catch up.

 /// 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    ///