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.3 / 7.3.195 < prev    next >
Encoding:
Internet Message Format  |  2012-11-20  |  4.8 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.195
  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.3.195
  11. Problem:    "} else" causes following lines to be indented too much. (Rouben
  12.         Rostamian)
  13. Solution:   Better detection for the "else". (Lech Lorens)
  14. Files:        src/misc1.c, src/testdir/test3.in, src/testdir/test3.ok
  15.  
  16.  
  17. *** ../vim-7.3.194/src/misc1.c    2011-05-10 16:41:13.000000000 +0200
  18. --- src/misc1.c    2011-05-19 16:30:28.000000000 +0200
  19. ***************
  20. *** 5482,5489 ****
  21.    * Recognize a line that starts with '{' or '}', or ends with ';', ',', '{' or
  22.    * '}'.
  23.    * Don't consider "} else" a terminated line.
  24. !  * Don't consider a line where there are unmatched opening braces before '}',
  25. !  * ';' or ',' a terminated line.
  26.    * Return the character terminating the line (ending char's have precedence if
  27.    * both apply in order to determine initializations).
  28.    */
  29. --- 5482,5489 ----
  30.    * Recognize a line that starts with '{' or '}', or ends with ';', ',', '{' or
  31.    * '}'.
  32.    * Don't consider "} else" a terminated line.
  33. !  * If a line begins with an "else", only consider it terminated if no unmatched
  34. !  * opening braces follow (handle "else { foo();" correctly).
  35.    * Return the character terminating the line (ending char's have precedence if
  36.    * both apply in order to determine initializations).
  37.    */
  38. ***************
  39. *** 5493,5513 ****
  40.       int        incl_open;    /* include '{' at the end as terminator */
  41.       int        incl_comma;    /* recognize a trailing comma */
  42.   {
  43. !     char_u found_start = 0;
  44. !     unsigned n_open = 0;
  45.   
  46.       s = cin_skipcomment(s);
  47.   
  48.       if (*s == '{' || (*s == '}' && !cin_iselse(s)))
  49.       found_start = *s;
  50.   
  51.       while (*s)
  52.       {
  53.       /* skip over comments, "" strings and 'c'haracters */
  54.       s = skip_string(cin_skipcomment(s));
  55.       if (*s == '}' && n_open > 0)
  56.           --n_open;
  57. !     if (n_open == 0
  58.           && (*s == ';' || *s == '}' || (incl_comma && *s == ','))
  59.           && cin_nocode(s + 1))
  60.           return *s;
  61. --- 5493,5517 ----
  62.       int        incl_open;    /* include '{' at the end as terminator */
  63.       int        incl_comma;    /* recognize a trailing comma */
  64.   {
  65. !     char_u    found_start = 0;
  66. !     unsigned    n_open = 0;
  67. !     int        is_else = FALSE;
  68.   
  69.       s = cin_skipcomment(s);
  70.   
  71.       if (*s == '{' || (*s == '}' && !cin_iselse(s)))
  72.       found_start = *s;
  73.   
  74. +     if (!found_start)
  75. +     is_else = cin_iselse(s);
  76.       while (*s)
  77.       {
  78.       /* skip over comments, "" strings and 'c'haracters */
  79.       s = skip_string(cin_skipcomment(s));
  80.       if (*s == '}' && n_open > 0)
  81.           --n_open;
  82. !     if ((!is_else || n_open == 0)
  83.           && (*s == ';' || *s == '}' || (incl_comma && *s == ','))
  84.           && cin_nocode(s + 1))
  85.           return *s;
  86. *** ../vim-7.3.194/src/testdir/test3.in    2011-05-10 13:38:23.000000000 +0200
  87. --- src/testdir/test3.in    2011-05-19 16:29:01.000000000 +0200
  88. ***************
  89. *** 1345,1351 ****
  90.   
  91.   STARTTEST
  92.   :set cino&
  93. ! 2kdd=][
  94.   ENDTEST
  95.   
  96.   void func(void)
  97. --- 1345,1351 ----
  98.   
  99.   STARTTEST
  100.   :set cino&
  101. ! 2kdd=4][
  102.   ENDTEST
  103.   
  104.   void func(void)
  105. ***************
  106. *** 1359,1364 ****
  107. --- 1359,1392 ----
  108.       printf("Foo!\n");
  109.   }
  110.   
  111. + void func1(void)
  112. + {
  113. +     char* tab[] = {"foo", "bar",
  114. +         "baz", "quux",
  115. +             "this line used", "to be indented incorrectly"};
  116. +     foo();
  117. + }
  118. + void func2(void)
  119. + {
  120. +     int tab[] =
  121. +     {1, 2,
  122. +         3, 4,
  123. +         5, 6};
  124. +         printf("This line used to be indented incorrectly.\n");
  125. + }
  126. + void func3(void)
  127. + {
  128. +     int tab[] = {
  129. +     1, 2,
  130. +     3, 4,
  131. +     5, 6};
  132. + printf("Don't you dare indent this line incorrectly!\n);
  133. + }
  134.   STARTTEST
  135.   :set cino&
  136.   2kdd=][
  137. *** ../vim-7.3.194/src/testdir/test3.ok    2011-05-10 13:38:23.000000000 +0200
  138. --- src/testdir/test3.ok    2011-05-19 16:29:01.000000000 +0200
  139. ***************
  140. *** 1216,1221 ****
  141. --- 1216,1249 ----
  142.       printf("Foo!\n");
  143.   }
  144.   
  145. + void func1(void)
  146. + {
  147. +     char* tab[] = {"foo", "bar",
  148. +         "baz", "quux",
  149. +         "this line used", "to be indented incorrectly"};
  150. +     foo();
  151. + }
  152. + void func2(void)
  153. + {
  154. +     int tab[] =
  155. +     {1, 2,
  156. +         3, 4,
  157. +         5, 6};
  158. +     printf("This line used to be indented incorrectly.\n");
  159. + }
  160. + void func3(void)
  161. + {
  162. +     int tab[] = {
  163. +         1, 2,
  164. +         3, 4,
  165. +         5, 6};
  166. +     printf("Don't you dare indent this line incorrectly!\n);
  167. + }
  168.   
  169.   void func(void)
  170.   {
  171. *** ../vim-7.3.194/src/version.c    2011-05-19 14:59:07.000000000 +0200
  172. --- src/version.c    2011-05-19 16:34:16.000000000 +0200
  173. ***************
  174. *** 711,712 ****
  175. --- 711,714 ----
  176.   {   /* Add new patch number below this line */
  177. + /**/
  178. +     195,
  179.   /**/
  180.  
  181. -- 
  182. I AM THANKFUL...
  183. ...for the taxes that I pay because it means that I am employed.
  184.  
  185.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  186. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  187. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  188.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  189.