home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.4 / 7.4.264 < prev    next >
Encoding:
Internet Message Format  |  2014-04-22  |  5.0 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.4.264
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.4.264 (after 7.4.260)
  11. Problem:    Can't define a function starting with "g:".  Can't assign a
  12.         funcref to a buffer-local variable.
  13. Solution:   Skip "g:" at the start of a function name.  Don't check for colons
  14.         when assigning to a variable.
  15. Files:        src/eval.c, src/testdir/test_eval.in, src/testdir/test_eval.ok
  16.  
  17.  
  18. *** ../vim-7.4.263/src/eval.c    2014-04-23 19:44:26.366774008 +0200
  19. --- src/eval.c    2014-04-23 20:40:16.738693276 +0200
  20. ***************
  21. *** 21583,21589 ****
  22.        * Get the function name.  There are these situations:
  23.        * func        normal function name
  24.        *            "name" == func, "fudi.fd_dict" == NULL
  25. -      * s:func        script-local function name
  26.        * dict.func    new dictionary entry
  27.        *            "name" == NULL, "fudi.fd_dict" set,
  28.        *            "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
  29. --- 21583,21588 ----
  30. ***************
  31. *** 21593,21598 ****
  32. --- 21592,21599 ----
  33.        * dict.func    existing dict entry that's not a Funcref
  34.        *            "name" == NULL, "fudi.fd_dict" set,
  35.        *            "fudi.fd_di" set, "fudi.fd_newkey" == NULL
  36. +      * s:func        script-local function name
  37. +      * g:func        global function name, same as "func"
  38.        */
  39.       p = eap->arg;
  40.       name = trans_function_name(&p, eap->skip, 0, &fudi);
  41. ***************
  42. *** 22286,22292 ****
  43.       }
  44.       else
  45.       {
  46. !     if (lead == 2)    /* skip over "s:" */
  47.           lv.ll_name += 2;
  48.       len = (int)(end - lv.ll_name);
  49.       }
  50. --- 22287,22294 ----
  51.       }
  52.       else
  53.       {
  54. !     /* skip over "s:" and "g:" */
  55. !     if (lead == 2 || (lv.ll_name[0] == 'g' && lv.ll_name[1] == ':'))
  56.           lv.ll_name += 2;
  57.       len = (int)(end - lv.ll_name);
  58.       }
  59. ***************
  60. *** 22317,22333 ****
  61.       else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len))
  62.       {
  63.       EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
  64. !                                   lv.ll_name);
  65.       goto theend;
  66.       }
  67. !     if (!skip)
  68.       {
  69.       char_u *cp = vim_strchr(lv.ll_name, ':');
  70.   
  71.       if (cp != NULL && cp < end)
  72.       {
  73. !         EMSG2(_("E884: Function name cannot contain a colon: %s"),
  74. !                                   lv.ll_name);
  75.           goto theend;
  76.       }
  77.       }
  78. --- 22319,22334 ----
  79.       else if (!(flags & TFN_INT) && builtin_function(lv.ll_name, len))
  80.       {
  81.       EMSG2(_("E128: Function name must start with a capital or \"s:\": %s"),
  82. !                                        start);
  83.       goto theend;
  84.       }
  85. !     if (!skip && !(flags & TFN_QUIET))
  86.       {
  87.       char_u *cp = vim_strchr(lv.ll_name, ':');
  88.   
  89.       if (cp != NULL && cp < end)
  90.       {
  91. !         EMSG2(_("E884: Function name cannot contain a colon: %s"), start);
  92.           goto theend;
  93.       }
  94.       }
  95. *** ../vim-7.4.263/src/testdir/test_eval.in    2014-04-23 17:43:37.362948683 +0200
  96. --- src/testdir/test_eval.in    2014-04-23 20:36:50.494698246 +0200
  97. ***************
  98. *** 144,150 ****
  99.   :delcommand AR
  100.   :call garbagecollect(1)
  101.   :"
  102. ! :" function name includes a colon
  103.   :try
  104.   :func! g:test()
  105.   :echo "test"
  106. --- 144,150 ----
  107.   :delcommand AR
  108.   :call garbagecollect(1)
  109.   :"
  110. ! :" function name not starting with capital
  111.   :try
  112.   :func! g:test()
  113.   :echo "test"
  114. ***************
  115. *** 153,158 ****
  116. --- 153,167 ----
  117.   :$put =v:exception
  118.   :endtry
  119.   :"
  120. + :" function name includes a colon
  121. + :try
  122. + :func! b:test()
  123. + :echo "test"
  124. + :endfunc
  125. + :catch
  126. + :$put =v:exception
  127. + :endtry
  128. + :"
  129.   :" function name folowed by #
  130.   :try
  131.   :func! test2() "#
  132. ***************
  133. *** 162,167 ****
  134. --- 171,183 ----
  135.   :$put =v:exception
  136.   :endtry
  137.   :"
  138. + :" function name starting with/without "g:", buffer-local funcref.
  139. + :function! g:Foo()
  140. + :  $put ='called Foo()'
  141. + :endfunction
  142. + :let b:my_func = function('Foo')
  143. + :call b:my_func()
  144. + :"
  145.   :/^start:/+1,$wq! test.out
  146.   :" vim: et ts=4 isk-=\: fmr=???,???
  147.   :call getchar()
  148. *** ../vim-7.4.263/src/testdir/test_eval.ok    2014-04-23 17:43:37.362948683 +0200
  149. --- src/testdir/test_eval.ok    2014-04-23 20:37:45.526696920 +0200
  150. ***************
  151. *** 336,339 ****
  152. --- 336,341 ----
  153.   Executing call setreg(1, ["", "", [], ""])
  154.   Vim(call):E730: using List as a String
  155.   Vim(function):E128: Function name must start with a capital or "s:": g:test()
  156. + Vim(function):E128: Function name must start with a capital or "s:": b:test()
  157.   Vim(function):E128: Function name must start with a capital or "s:": test2() "#
  158. + called Foo()
  159. *** ../vim-7.4.263/src/version.c    2014-04-23 19:44:26.370774008 +0200
  160. --- src/version.c    2014-04-23 20:27:17.614712050 +0200
  161. ***************
  162. *** 736,737 ****
  163. --- 736,739 ----
  164.   {   /* Add new patch number below this line */
  165. + /**/
  166. +     264,
  167.   /**/
  168.  
  169. -- 
  170. In order for something to become clean, something else must become dirty;
  171. but you can get everything dirty without getting anything clean.
  172.  
  173.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  174. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  175. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  176.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  177.