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 / unreleased / patches / 5.6a.003 < prev    next >
Encoding:
Internet Message Format  |  1999-12-20  |  5.8 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 5.6a.003
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. ------------
  6.  
  7. Patch 5.6a.003
  8. Problem:    Defining a function inside a function didn't give an error
  9.         message.  A missing ":endfunction" doesn't give an error message.
  10. Solution:   Allow defining a function inside a function.
  11. Files:        src/eval.c, runtime/doc/eval.txt
  12.  
  13.  
  14. *** ../vim-5.6a.2/src/eval.c    Mon Dec 20 09:59:08 1999
  15. --- src/eval.c    Tue Dec 21 12:32:17 1999
  16. ***************
  17. *** 4737,4742 ****
  18. --- 4782,4788 ----
  19.       int        flags = 0;
  20.       struct ufunc *fp;
  21.       int        indent;
  22. +     int        nesting;
  23.   
  24.       /*
  25.        * ":function" without argument: list functions.
  26. ***************
  27. *** 4881,4886 ****
  28. --- 4927,4933 ----
  29.       cmdline_row = msg_row;
  30.       }
  31.       indent = 2;
  32. +     nesting = 0;
  33.       for (;;)
  34.       {
  35.       msg_scroll = TRUE;
  36. ***************
  37. *** 4891,4901 ****
  38.           theline = getline(':', cookie, indent);
  39.       lines_left = Rows - 1;
  40.       if (theline == NULL)
  41.           goto erret;
  42.   
  43.       for (p = theline; vim_iswhite(*p) || *p == ':'; ++p)
  44.           ;
  45. !     if (STRNCMP(p, "endf", 4) == 0)
  46.       {
  47.           vim_free(theline);
  48.           break;
  49. --- 4938,4951 ----
  50.           theline = getline(':', cookie, indent);
  51.       lines_left = Rows - 1;
  52.       if (theline == NULL)
  53. +     {
  54. +         EMSG("Missing :endfunction");
  55.           goto erret;
  56. +     }
  57.   
  58.       for (p = theline; vim_iswhite(*p) || *p == ':'; ++p)
  59.           ;
  60. !     if (STRNCMP(p, "endf", 4) == 0 && nesting-- == 0)
  61.       {
  62.           vim_free(theline);
  63.           break;
  64. ***************
  65. *** 4904,4909 ****
  66. --- 4954,4974 ----
  67.           indent -= 2;
  68.       else if (STRNCMP(p, "if", 2) == 0 || STRNCMP(p, "wh", 2) == 0)
  69.           indent += 2;
  70. +     /* Check for defining a function inside this function. */
  71. +     if (STRNCMP(p, "fu", 2) == 0)
  72. +     {
  73. +         p = skipwhite(skiptowhite(p));
  74. +         if (isupper(*p))
  75. +         {
  76. +         while (isalpha(*p) || isdigit(*p) || *p == '_')
  77. +             ++p;
  78. +         if (*skipwhite(p) == '(')
  79. +         {
  80. +             ++nesting;
  81. +             indent += 2;
  82. +         }
  83. +         }
  84. +     }
  85.       if (ga_grow(&newlines, 1) == FAIL)
  86.           goto erret;
  87.       ((char_u **)(newlines.ga_data))[newlines.ga_len] = theline;
  88. *** ../vim-5.6a.2/runtime/doc/eval.txt    Mon Dec 20 09:59:29 1999
  89. --- runtime/doc/eval.txt    Tue Dec 21 12:20:00 1999
  90. ***************
  91. *** 1,4 ****
  92. ! *eval.txt*      For Vim version 5.6a.  Last change: 1999 Dec 04
  93.   
  94.   
  95.             VIM REFERENCE MANUAL    by Bram Moolenaar
  96. --- 1,4 ----
  97. ! *eval.txt*      For Vim version 5.6a.  Last change: 1999 Dec 21
  98.   
  99.   
  100.             VIM REFERENCE MANUAL    by Bram Moolenaar
  101. ***************
  102. *** 195,201 ****
  103.   results in the mathematical difference (comparing byte values), not
  104.   necessarily the alphabetical difference in the local language.
  105.   
  106. ! When using the opreators with a trailing '#", or the short version and
  107.   'ignorecase' is off, the comparing is done with strcmp().
  108.   
  109.   When using the operators with a trailing '?', or the short version and
  110. --- 195,201 ----
  111.   results in the mathematical difference (comparing byte values), not
  112.   necessarily the alphabetical difference in the local language.
  113.   
  114. ! When using the operators with a trailing '#", or the short version and
  115.   'ignorecase' is off, the comparing is done with strcmp().
  116.   
  117.   When using the operators with a trailing '?', or the short version and
  118. ***************
  119. *** 1432,1440 ****
  120.   ==============================================================================
  121.   5. Defining functions                    *user-functions*
  122.   
  123. ! New functions can be defined.  These can be called with "Name()", just like
  124. ! builtin functions.  The name must start with an uppercase letter, to avoid
  125. ! confusion with builtin functions.
  126.   
  127.                               *:fu* *:function*
  128.   :fu[nction]        List all functions and their arguments.
  129. --- 1432,1444 ----
  130.   ==============================================================================
  131.   5. Defining functions                    *user-functions*
  132.   
  133. ! New functions can be defined.  These can be called just like builtin
  134. ! functions.
  135. ! The function name must start with an uppercase letter, to avoid confusion with
  136. ! builtin functions.  To prevent from using the same name in different scripts
  137. ! avoid obvious, short names.  A good habit is to start the function name with
  138. ! the name of the script, e.g., "HTMLcolor()".
  139.   
  140.                               *:fu* *:function*
  141.   :fu[nction]        List all functions and their arguments.
  142. ***************
  143. *** 1461,1467 ****
  144.               It is also possible to define a function without any
  145.               arguments.  You must still supply the () then.
  146.               The body of the function follows in the next lines,
  147. !             until ":endfunction".
  148.               When a function by this name already exists and [!] is
  149.               not used an error message is given.  When [!] is used,
  150.               an existing function is silently replaced.
  151. --- 1465,1472 ----
  152.               It is also possible to define a function without any
  153.               arguments.  You must still supply the () then.
  154.               The body of the function follows in the next lines,
  155. !             until the matching |:endfunction|.  It is allowed to
  156. !             define another function inside a function body.
  157.               When a function by this name already exists and [!] is
  158.               not used an error message is given.  When [!] is used,
  159.               an existing function is silently replaced.
  160. *** ../vim-5.6a.2/src/version.c    Tue Dec 21 12:21:20 1999
  161. --- src/version.c    Tue Dec 21 12:21:44 1999
  162. ***************
  163. *** 420,421 ****
  164. --- 420,423 ----
  165.   {   /* Add new patch number below this line */
  166. + /**/
  167. +     3,
  168.   /**/
  169.  
  170. -- 
  171. So when I saw the post to comp.editors, I rushed over to the FTP site to
  172. grab it.  So I yank apart the tarball, light x candles, where x= the
  173. vim version multiplied by the md5sum of the source divided by the MAC of
  174. my NIC (8A3FA78155A8A1D346C3C4A), put on black robes, dim the lights,
  175. wave a dead chicken over the hard drive, and summon the power of GNU GCC
  176. with the magic words "make config ; make!".
  177.         [Jason Spence, compiling Vim 5.0]
  178.  
  179. --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\--
  180.   \ \    www.vim.org/iccf      www.moolenaar.net       www.vim.org    / /
  181.