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 / 6.2.219 < prev    next >
Encoding:
Internet Message Format  |  2004-01-31  |  5.4 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.219
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.2.219
  11. Problem:    Syntax highlighting hangs on an empty match of an item with a
  12.         nextgroup.  (Charles Campbell)
  13. Solution:   Remember that the item has already matched and don't match it
  14.         again at the same position.
  15. Files:        src/syntax.c
  16.  
  17.  
  18. *** ../vim-6.2.218/src/syntax.c    Sat Sep 27 19:26:33 2003
  19. --- src/syntax.c    Thu Jan 29 21:14:40 2004
  20. ***************
  21. *** 348,354 ****
  22.   static void validate_current_state __ARGS((void));
  23.   static int syn_finish_line __ARGS((int syncing));
  24.   static int syn_current_attr __ARGS((int syncing, int displaying));
  25. ! static int did_match_already __ARGS((int idx));
  26.   static stateitem_T *push_next_match __ARGS((stateitem_T *cur_si));
  27.   static void check_state_ends __ARGS((void));
  28.   static void update_si_attr __ARGS((int idx));
  29. --- 348,354 ----
  30.   static void validate_current_state __ARGS((void));
  31.   static int syn_finish_line __ARGS((int syncing));
  32.   static int syn_current_attr __ARGS((int syncing, int displaying));
  33. ! static int did_match_already __ARGS((int idx, garray_T *gap));
  34.   static stateitem_T *push_next_match __ARGS((stateitem_T *cur_si));
  35.   static void check_state_ends __ARGS((void));
  36.   static void update_si_attr __ARGS((int idx));
  37. ***************
  38. *** 1730,1737 ****
  39. --- 1730,1740 ----
  40.       reg_extmatch_T *cur_extmatch = NULL;
  41.       char_u    *line;        /* current line.  NOTE: becomes invalid after
  42.                      looking for a pattern match! */
  43. +     /* variables for zero-width matches that have a "nextgroup" argument */
  44.       int        keep_next_list;
  45.       int        zero_width_next_list = FALSE;
  46. +     garray_T    zero_width_next_ga;
  47.   
  48.       /*
  49.        * No character, no attributes!  Past end of line?
  50. ***************
  51. *** 1775,1780 ****
  52. --- 1778,1787 ----
  53.               && (syn_buf->b_keywtab != NULL
  54.                   || syn_buf->b_keywtab_ic != NULL);
  55.   
  56. +     /* Init the list of zero-width matches with a nextlist.  This is used to
  57. +      * avoid matching the same item in the same position twice. */
  58. +     ga_init2(&zero_width_next_ga, sizeof(int), 10);
  59.       /*
  60.        * Repeat matching keywords and patterns, to find contained items at the
  61.        * same column.  This stops when there are no extra matches at the current
  62. ***************
  63. *** 1951,1957 ****
  64.                    * before, skip it.  Must retry in the next
  65.                    * column, because it may match from there.
  66.                    */
  67. !                 if (did_match_already(idx))
  68.                   {
  69.                   try_next_column = TRUE;
  70.                   continue;
  71. --- 1958,1964 ----
  72.                    * before, skip it.  Must retry in the next
  73.                    * column, because it may match from there.
  74.                    */
  75. !                 if (did_match_already(idx, &zero_width_next_ga))
  76.                   {
  77.                   try_next_column = TRUE;
  78.                   continue;
  79. ***************
  80. *** 2070,2075 ****
  81. --- 2077,2092 ----
  82.               current_next_flags = lspp->sp_flags;
  83.               keep_next_list = TRUE;
  84.               zero_width_next_list = TRUE;
  85. +             /* Add the index to a list, so that we can check
  86. +              * later that we don't match it again (and cause an
  87. +              * endless loop). */
  88. +             if (ga_grow(&zero_width_next_ga, 1) == OK)
  89. +             {
  90. +                 ((int *)(zero_width_next_ga.ga_data))
  91. +                 [zero_width_next_ga.ga_len++] = next_match_idx;
  92. +                 --zero_width_next_ga.ga_room;
  93. +             }
  94.               next_match_idx = -1;
  95.               }
  96.               else
  97. ***************
  98. *** 2172,2177 ****
  99. --- 2189,2197 ----
  100.           && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY)))
  101.       current_next_list = NULL;
  102.   
  103. +     if (zero_width_next_ga.ga_len > 0)
  104. +     ga_clear(&zero_width_next_ga);
  105.       /* No longer need external matches.  But keep next_match_extmatch. */
  106.       unref_extmatch(re_extmatch_out);
  107.       re_extmatch_out = NULL;
  108. ***************
  109. *** 2185,2202 ****
  110.    * Check if we already matched pattern "idx" at the current column.
  111.    */
  112.       static int
  113. ! did_match_already(idx)
  114. !     int        idx;
  115.   {
  116.       int        i;
  117.   
  118.       for (i = current_state.ga_len; --i >= 0; )
  119. -     {
  120.       if (CUR_STATE(i).si_m_startcol == (int)current_col
  121.           && CUR_STATE(i).si_m_lnum == (int)current_lnum
  122.           && CUR_STATE(i).si_idx == idx)
  123.           return TRUE;
  124. !     }
  125.       return FALSE;
  126.   }
  127.   
  128. --- 2205,2228 ----
  129.    * Check if we already matched pattern "idx" at the current column.
  130.    */
  131.       static int
  132. ! did_match_already(idx, gap)
  133. !     int        idx;
  134. !     garray_T    *gap;
  135.   {
  136.       int        i;
  137.   
  138.       for (i = current_state.ga_len; --i >= 0; )
  139.       if (CUR_STATE(i).si_m_startcol == (int)current_col
  140.           && CUR_STATE(i).si_m_lnum == (int)current_lnum
  141.           && CUR_STATE(i).si_idx == idx)
  142.           return TRUE;
  143. !     /* Zero-width matches with a nextgroup argument are not put on the syntax
  144. !      * stack, and can only be matched once anyway. */
  145. !     for (i = gap->ga_len; --i >= 0; )
  146. !     if (((int *)(gap->ga_data))[i] == idx)
  147. !         return TRUE;
  148.       return FALSE;
  149.   }
  150.   
  151. *** ../vim-6.2.218/src/version.c    Sun Feb  1 19:59:21 2004
  152. --- src/version.c    Sun Feb  1 20:00:45 2004
  153. ***************
  154. *** 639,640 ****
  155. --- 639,642 ----
  156.   {   /* Add new patch number below this line */
  157. + /**/
  158. +     219,
  159.   /**/
  160.  
  161. -- 
  162. The Feynman problem solving Algorithm:
  163.     1) Write down the problem
  164.     2) Think real hard
  165.     3) Write down the answer
  166.  
  167.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  168. ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  169. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  170.  \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///
  171.