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.844 < prev    next >
Encoding:
Internet Message Format  |  2013-03-06  |  5.8 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.844
  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.844
  11. Problem:    Enum is not indented correctly with "public" etc.
  12. Solution:   Skip "public", "private" and "protected". (Hong Xu)
  13. Files:        src/misc1.c
  14.  
  15.  
  16. *** ../vim-7.3.843/src/misc1.c    2013-02-13 16:10:13.000000000 +0100
  17. --- src/misc1.c    2013-03-07 12:59:45.000000000 +0100
  18. ***************
  19. *** 5275,5280 ****
  20. --- 5275,5281 ----
  21.   static int    cin_is_cpp_baseclass __ARGS((colnr_T *col));
  22.   static int    get_baseclass_amount __ARGS((int col, int ind_maxparen, int ind_maxcomment, int ind_cpp_baseclass));
  23.   static int    cin_ends_in __ARGS((char_u *, char_u *, char_u *));
  24. + static int    cin_starts_with __ARGS((char_u *s, char *word));
  25.   static int    cin_skip2pos __ARGS((pos_T *trypos));
  26.   static pos_T    *find_start_brace __ARGS((int));
  27.   static pos_T    *find_match_paren __ARGS((int, int));
  28. ***************
  29. *** 5446,5469 ****
  30.   }
  31.   
  32.   /*
  33. !  * Recognize structure initialization and enumerations.
  34. !  * Q&D-Implementation:
  35. !  * check for "=" at end or "[typedef] enum" at beginning of line.
  36.    */
  37.       static int
  38.   cin_isinit(void)
  39.   {
  40.       char_u    *s;
  41.   
  42.       s = cin_skipcomment(ml_get_curline());
  43.   
  44. !     if (STRNCMP(s, "typedef", 7) == 0 && !vim_isIDc(s[7]))
  45.       s = cin_skipcomment(s + 7);
  46.   
  47. !     if (STRNCMP(s, "static", 6) == 0 && !vim_isIDc(s[6]))
  48. !     s = cin_skipcomment(s + 6);
  49.   
  50. !     if (STRNCMP(s, "enum", 4) == 0 && !vim_isIDc(s[4]))
  51.       return TRUE;
  52.   
  53.       if (cin_ends_in(s, (char_u *)"=", (char_u *)"{"))
  54. --- 5447,5486 ----
  55.   }
  56.   
  57.   /*
  58. !  * Recognize structure initialization and enumerations:
  59. !  * "[typedef] [static|public|protected|private] enum"
  60. !  * "[typedef] [static|public|protected|private] = {"
  61.    */
  62.       static int
  63.   cin_isinit(void)
  64.   {
  65.       char_u    *s;
  66. +     static char *skip[] = {"static", "public", "protected", "private"};
  67.   
  68.       s = cin_skipcomment(ml_get_curline());
  69.   
  70. !     if (cin_starts_with(s, "typedef"))
  71.       s = cin_skipcomment(s + 7);
  72.   
  73. !     for (;;)
  74. !     {
  75. !     int i, l;
  76. !     for (i = 0; i < (int)(sizeof(skip) / sizeof(char *)); ++i)
  77. !     {
  78. !         l = strlen(skip[i]);
  79. !         if (cin_starts_with(s, skip[i]))
  80. !         {
  81. !         s = cin_skipcomment(s + l);
  82. !         l = 0;
  83. !         break;
  84. !         }
  85. !     }
  86. !     if (l != 0)
  87. !         break;
  88. !     }
  89.   
  90. !     if (cin_starts_with(s, "enum"))
  91.       return TRUE;
  92.   
  93.       if (cin_ends_in(s, (char_u *)"=", (char_u *)"{"))
  94. ***************
  95. *** 5481,5487 ****
  96.       int strict; /* Allow relaxed check of case statement for JS */
  97.   {
  98.       s = cin_skipcomment(s);
  99. !     if (STRNCMP(s, "case", 4) == 0 && !vim_isIDc(s[4]))
  100.       {
  101.       for (s += 4; *s; ++s)
  102.       {
  103. --- 5498,5504 ----
  104.       int strict; /* Allow relaxed check of case statement for JS */
  105.   {
  106.       s = cin_skipcomment(s);
  107. !     if (cin_starts_with(s, "case"))
  108.       {
  109.       for (s += 4; *s; ++s)
  110.       {
  111. ***************
  112. *** 6049,6055 ****
  113.       p = cin_skipcomment(p);
  114.       if (*p == '}')        /* accept "} while (cond);" */
  115.       p = cin_skipcomment(p + 1);
  116. !     if (STRNCMP(p, "while", 5) == 0 && !vim_isIDc(p[5]))
  117.       {
  118.       cursor_save = curwin->w_cursor;
  119.       curwin->w_cursor.lnum = lnum;
  120. --- 6066,6072 ----
  121.       p = cin_skipcomment(p);
  122.       if (*p == '}')        /* accept "} while (cond);" */
  123.       p = cin_skipcomment(p + 1);
  124. !     if (cin_starts_with(p, "while"))
  125.       {
  126.       cursor_save = curwin->w_cursor;
  127.       curwin->w_cursor.lnum = lnum;
  128. ***************
  129. *** 6156,6162 ****
  130.               s = cin_skipcomment(ml_get(trypos->lnum));
  131.               if (*s == '}')        /* accept "} while (cond);" */
  132.               s = cin_skipcomment(s + 1);
  133. !             if (STRNCMP(s, "while", 5) == 0 && !vim_isIDc(s[5]))
  134.               {
  135.               curwin->w_cursor.lnum = trypos->lnum;
  136.               return TRUE;
  137. --- 6173,6179 ----
  138.               s = cin_skipcomment(ml_get(trypos->lnum));
  139.               if (*s == '}')        /* accept "} while (cond);" */
  140.               s = cin_skipcomment(s + 1);
  141. !             if (cin_starts_with(s, "while"))
  142.               {
  143.               curwin->w_cursor.lnum = trypos->lnum;
  144.               return TRUE;
  145. ***************
  146. *** 6406,6411 ****
  147. --- 6423,6441 ----
  148.   }
  149.   
  150.   /*
  151. +  * Return TRUE when "s" starts with "word" and then a non-ID character.
  152. +  */
  153. +     static int
  154. + cin_starts_with(s, word)
  155. +     char_u *s;
  156. +     char *word;
  157. + {
  158. +     int l = STRLEN(word);
  159. +     return (STRNCMP(s, word, l) == 0 && !vim_isIDc(s[l]));
  160. + }
  161. + /*
  162.    * Skip strings, chars and comments until at or past "trypos".
  163.    * Return the column found.
  164.    */
  165. *** ../vim-7.3.843/src/version.c    2013-02-26 22:54:06.000000000 +0100
  166. --- src/version.c    2013-03-07 13:12:20.000000000 +0100
  167. ***************
  168. *** 730,731 ****
  169. --- 730,733 ----
  170.   {   /* Add new patch number below this line */
  171. + /**/
  172. +     844,
  173.   /**/
  174.  
  175. -- 
  176. Now it is such a bizarrely improbable coincidence that anything as
  177. mind-bogglingly useful as the Babel fish could have evolved purely by chance
  178. that some thinkers have chosen to see it as a final and clinching proof of the
  179. NON-existence of God.
  180. The argument goes something like this: 'I refuse to prove that I exist,' says
  181. God, 'for proof denies faith, and without faith I am nothing.'
  182. 'But,' says Man, 'the Babel fish is a dead giveaway, isn't it?  It could not
  183. have evolved by chance.  It proves you exist, and so therefore, by your own
  184. arguments, you don't.  QED.'
  185. 'Oh dear,' says God, 'I hadn't thought of that,' and promptly vanishes in a
  186. puff of logic.
  187. 'Oh, that was easy,' says Man, and for an encore goes on to prove that black
  188. is white and gets himself killed on the next pedestrian crossing.
  189.         -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
  190.  
  191.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  192. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  193. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  194.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  195.