1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: A syntax file with a huge number of items or clusters causes weird
12 behavior, a hang or a crash. (Yukihiro Nakadaira)
13 Solution: Check running out of IDs. (partly by Ben Schmidt)
17 *** ../vim-7.3.147/src/syntax.c 2011-01-22 00:58:15.000000000 +0100
18 --- src/syntax.c 2011-04-01 14:25:39.000000000 +0200
23 * Syntax group IDs have different types:
24 ! * 0 - 9999 normal syntax groups
25 ! * 10000 - 14999 ALLBUT indicator (current_syn_inc_tag added)
26 ! * 15000 - 19999 TOP indicator (current_syn_inc_tag added)
27 ! * 20000 - 24999 CONTAINED indicator (current_syn_inc_tag added)
28 ! * >= 25000 cluster IDs (subtract SYNID_CLUSTER for the cluster ID)
30 ! #define SYNID_ALLBUT 10000 /* syntax group ID for contains=ALLBUT */
31 ! #define SYNID_TOP 15000 /* syntax group ID for contains=TOP */
32 ! #define SYNID_CONTAINED 20000 /* syntax group ID for contains=CONTAINED */
33 ! #define SYNID_CLUSTER 25000 /* first syntax group ID for clusters */
36 * Annoying Hack(TM): ":syn include" needs this pointer to pass to
40 * Syntax group IDs have different types:
41 ! * 0 - 19999 normal syntax groups
42 ! * 20000 - 20999 ALLBUT indicator (current_syn_inc_tag added)
43 ! * 21000 - 21999 TOP indicator (current_syn_inc_tag added)
44 ! * 22000 - 22999 CONTAINED indicator (current_syn_inc_tag added)
45 ! * 23000 - 32767 cluster IDs (subtract SYNID_CLUSTER for the cluster ID)
47 ! #define SYNID_ALLBUT 20000 /* syntax group ID for contains=ALLBUT */
48 ! #define SYNID_TOP 21000 /* syntax group ID for contains=TOP */
49 ! #define SYNID_CONTAINED 22000 /* syntax group ID for contains=CONTAINED */
50 ! #define SYNID_CLUSTER 23000 /* first syntax group ID for clusters */
52 ! #define MAX_SYNID SYNID_ALLBUT
53 ! #define MAX_SYN_INC_TAG 999 /* maximum before the above overflow */
54 ! #define MAX_CLUSTER_ID (32767 - SYNID_CLUSTER)
57 * Annoying Hack(TM): ":syn include" needs this pointer to pass to
61 /* free the stored states */
62 syn_stack_free_all(block);
63 invalidate_current_state();
65 + /* Reset the counter for ":syn include" */
66 + running_syn_inc_tag = 0;
75 sgl_id = syn_check_cluster(arg, (int)(group_name_end - arg));
78 /* separate_nextcmd() and expand_filename() depend on this */
84 * Save and restore the existing top-level grouplist id and ":syn
85 * include" tag around the actual inclusion.
87 + if (running_syn_inc_tag >= MAX_SYN_INC_TAG)
89 + EMSG((char_u *)_("E847: Too many syntax includes"));
92 prev_syn_inc_tag = current_syn_inc_tag;
93 current_syn_inc_tag = ++running_syn_inc_tag;
94 prev_toplvl_grp = curwin->w_s->b_syn_topgrp;
97 char_u *group_name_end;
100 ! char_u *keyword_copy;
103 syn_opt_arg_T syn_opt_arg;
105 char_u *group_name_end;
108 ! char_u *keyword_copy = NULL;
111 syn_opt_arg_T syn_opt_arg;
116 syn_id = syn_check_group(arg, (int)(group_name_end - arg));
118 ! /* allocate a buffer, for removing the backslashes in the keyword */
119 ! keyword_copy = alloc((unsigned)STRLEN(rest) + 1);
120 if (keyword_copy != NULL)
122 syn_opt_arg.flags = 0;
126 syn_id = syn_check_group(arg, (int)(group_name_end - arg));
128 ! /* allocate a buffer, for removing backslashes in the keyword */
129 ! keyword_copy = alloc((unsigned)STRLEN(rest) + 1);
130 if (keyword_copy != NULL)
132 syn_opt_arg.flags = 0;
135 (item == ITEM_SKIP) ? SPTYPE_SKIP : SPTYPE_END;
136 SYN_ITEMS(curwin->w_s)[idx].sp_flags |= syn_opt_arg.flags;
137 SYN_ITEMS(curwin->w_s)[idx].sp_syn.id = syn_id;
138 ! SYN_ITEMS(curwin->w_s)[idx].sp_syn.inc_tag = current_syn_inc_tag;
139 SYN_ITEMS(curwin->w_s)[idx].sp_syn_match_id =
140 ppp->pp_matchgroup_id;
143 (item == ITEM_SKIP) ? SPTYPE_SKIP : SPTYPE_END;
144 SYN_ITEMS(curwin->w_s)[idx].sp_flags |= syn_opt_arg.flags;
145 SYN_ITEMS(curwin->w_s)[idx].sp_syn.id = syn_id;
146 ! SYN_ITEMS(curwin->w_s)[idx].sp_syn.inc_tag =
147 ! current_syn_inc_tag;
148 SYN_ITEMS(curwin->w_s)[idx].sp_syn_match_id =
149 ppp->pp_matchgroup_id;
154 curwin->w_s->b_syn_clusters.ga_growsize = 10;
157 + len = curwin->w_s->b_syn_clusters.ga_len;
158 + if (len >= MAX_CLUSTER_ID)
160 + EMSG((char_u *)_("E848: Too many syntax clusters"));
166 * Make room for at least one other cluster entry.
173 - len = curwin->w_s->b_syn_clusters.ga_len;
175 vim_memset(&(SYN_CLSTR(curwin->w_s)[len]), 0, sizeof(syn_cluster_T));
176 SYN_CLSTR(curwin->w_s)[len].scl_name = name;
183 ! scl_id = syn_check_cluster(arg, (int)(group_name_end - arg))
192 ! scl_id = syn_check_cluster(arg, (int)(group_name_end - arg));
195 ! scl_id -= SYNID_CLUSTER;
203 redraw_curbuf_later(SOME_VALID);
204 ! syn_stack_free_all(curwin->w_s); /* Need to recompute all syntax. */
211 redraw_curbuf_later(SOME_VALID);
212 ! syn_stack_free_all(curwin->w_s); /* Need to recompute all. */
219 highlight_ga.ga_growsize = 10;
222 + if (highlight_ga.ga_len >= MAX_SYNID)
224 + EMSG(_("E849: Too many syntax groups"));
230 * Make room for at least one other syntax_highlight entry.
232 *** ../vim-7.3.147/src/version.c 2011-04-01 13:05:37.000000000 +0200
233 --- src/version.c 2011-04-01 14:26:44.000000000 +0200
237 { /* Add new patch number below this line */
243 BLACK KNIGHT: None shall pass.
244 ARTHUR: I have no quarrel with you, brave Sir knight, but I must cross
246 BLACK KNIGHT: Then you shall die.
247 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
249 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
250 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
251 \\\ an exciting new programming language -- http://www.Zimbu.org ///
252 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///