]> git.pld-linux.org Git - packages/vim.git/blob - 6.2.219
- initial import
[packages/vim.git] / 6.2.219
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
44 +     /* variables for zero-width matches that have a "nextgroup" argument */
45       int               keep_next_list;
46       int               zero_width_next_list = FALSE;
47 +     garray_T  zero_width_next_ga;
48   
49       /*
50        * No character, no attributes!  Past end of line?
51 ***************
52 *** 1775,1780 ****
53 --- 1778,1787 ----
54                     && (syn_buf->b_keywtab != NULL
55                             || syn_buf->b_keywtab_ic != NULL);
56   
57 +     /* Init the list of zero-width matches with a nextlist.  This is used to
58 +      * avoid matching the same item in the same position twice. */
59 +     ga_init2(&zero_width_next_ga, sizeof(int), 10);
60
61       /*
62        * Repeat matching keywords and patterns, to find contained items at the
63        * same column.  This stops when there are no extra matches at the current
64 ***************
65 *** 1951,1957 ****
66                              * before, skip it.  Must retry in the next
67                              * column, because it may match from there.
68                              */
69 !                           if (did_match_already(idx))
70                             {
71                                 try_next_column = TRUE;
72                                 continue;
73 --- 1958,1964 ----
74                              * before, skip it.  Must retry in the next
75                              * column, because it may match from there.
76                              */
77 !                           if (did_match_already(idx, &zero_width_next_ga))
78                             {
79                                 try_next_column = TRUE;
80                                 continue;
81 ***************
82 *** 2070,2075 ****
83 --- 2077,2092 ----
84                         current_next_flags = lspp->sp_flags;
85                         keep_next_list = TRUE;
86                         zero_width_next_list = TRUE;
87
88 +                       /* Add the index to a list, so that we can check
89 +                        * later that we don't match it again (and cause an
90 +                        * endless loop). */
91 +                       if (ga_grow(&zero_width_next_ga, 1) == OK)
92 +                       {
93 +                           ((int *)(zero_width_next_ga.ga_data))
94 +                               [zero_width_next_ga.ga_len++] = next_match_idx;
95 +                           --zero_width_next_ga.ga_room;
96 +                       }
97                         next_match_idx = -1;
98                     }
99                     else
100 ***************
101 *** 2172,2177 ****
102 --- 2189,2197 ----
103             && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY)))
104         current_next_list = NULL;
105   
106 +     if (zero_width_next_ga.ga_len > 0)
107 +       ga_clear(&zero_width_next_ga);
108
109       /* No longer need external matches.  But keep next_match_extmatch. */
110       unref_extmatch(re_extmatch_out);
111       re_extmatch_out = NULL;
112 ***************
113 *** 2185,2202 ****
114    * Check if we already matched pattern "idx" at the current column.
115    */
116       static int
117 ! did_match_already(idx)
118 !     int           idx;
119   {
120       int               i;
121   
122       for (i = current_state.ga_len; --i >= 0; )
123 -     {
124         if (CUR_STATE(i).si_m_startcol == (int)current_col
125                 && CUR_STATE(i).si_m_lnum == (int)current_lnum
126                 && CUR_STATE(i).si_idx == idx)
127             return TRUE;
128 !     }
129       return FALSE;
130   }
131   
132 --- 2205,2228 ----
133    * Check if we already matched pattern "idx" at the current column.
134    */
135       static int
136 ! did_match_already(idx, gap)
137 !     int               idx;
138 !     garray_T  *gap;
139   {
140       int               i;
141   
142       for (i = current_state.ga_len; --i >= 0; )
143         if (CUR_STATE(i).si_m_startcol == (int)current_col
144                 && CUR_STATE(i).si_m_lnum == (int)current_lnum
145                 && CUR_STATE(i).si_idx == idx)
146             return TRUE;
147
148 !     /* Zero-width matches with a nextgroup argument are not put on the syntax
149 !      * stack, and can only be matched once anyway. */
150 !     for (i = gap->ga_len; --i >= 0; )
151 !       if (((int *)(gap->ga_data))[i] == idx)
152 !           return TRUE;
153
154       return FALSE;
155   }
156   
157 *** ../vim-6.2.218/src/version.c        Sun Feb  1 19:59:21 2004
158 --- src/version.c       Sun Feb  1 20:00:45 2004
159 ***************
160 *** 639,640 ****
161 --- 639,642 ----
162   {   /* Add new patch number below this line */
163 + /**/
164 +     219,
165   /**/
166
167 -- 
168 The Feynman problem solving Algorithm:
169         1) Write down the problem
170         2) Think real hard
171         3) Write down the answer
172
173  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
174 ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
175 \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
176  \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///
This page took 0.037233 seconds and 3 git commands to generate.