summaryrefslogtreecommitdiffstats
path: root/source/ap/vim/patches/7.3.109
blob: ce35fb0ad72878212023256f4a6067a95c52aebf (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
To: vim_dev@googlegroups.com
Subject: Patch 7.3.109
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.109
Problem:    Processing new Esperanto spell file fails and crashes Vim.
	    (Dominique Pelle)
Solution:   When running out of memory give an error.  Handle '?' in
	    COMPOUNDRULE properly.
Files:	    src/spell.c


*** ../vim-7.3.108/src/spell.c	2010-12-17 18:06:00.000000000 +0100
--- src/spell.c	2011-02-01 13:43:52.000000000 +0100
***************
*** 3634,3640 ****
  	}
  
  	/* Add all flags to "sl_compallflags". */
! 	if (vim_strchr((char_u *)"+*[]/", c) == NULL
  		&& !byte_in_str(slang->sl_compallflags, c))
  	{
  	    *ap++ = c;
--- 3634,3640 ----
  	}
  
  	/* Add all flags to "sl_compallflags". */
! 	if (vim_strchr((char_u *)"?*+[]/", c) == NULL
  		&& !byte_in_str(slang->sl_compallflags, c))
  	{
  	    *ap++ = c;
***************
*** 3664,3670 ****
  	/* Copy flag to "sl_comprules", unless we run into a wildcard. */
  	if (crp != NULL)
  	{
! 	    if (c == '+' || c == '*')
  	    {
  		vim_free(slang->sl_comprules);
  		slang->sl_comprules = NULL;
--- 3664,3670 ----
  	/* Copy flag to "sl_comprules", unless we run into a wildcard. */
  	if (crp != NULL)
  	{
! 	    if (c == '?' || c == '+' || c == '*')
  	    {
  		vim_free(slang->sl_comprules);
  		slang->sl_comprules = NULL;
***************
*** 3682,3689 ****
  	}
  	else		    /* normal char, "[abc]" and '*' are copied as-is */
  	{
! 	    if (c == '+' || c == '~')
! 		*pp++ = '\\';	    /* "a+" becomes "a\+" */
  #ifdef FEAT_MBYTE
  	    if (enc_utf8)
  		pp += mb_char2bytes(c, pp);
--- 3682,3689 ----
  	}
  	else		    /* normal char, "[abc]" and '*' are copied as-is */
  	{
! 	    if (c == '?' || c == '+' || c == '~')
! 		*pp++ = '\\';	    /* "a?" becomes "a\?", "a+" becomes "a\+" */
  #ifdef FEAT_MBYTE
  	    if (enc_utf8)
  		pp += mb_char2bytes(c, pp);
***************
*** 4951,4956 ****
--- 4951,4958 ----
  
      sblock_T	*si_blocks;	/* memory blocks used */
      long	si_blocks_cnt;	/* memory blocks allocated */
+     int		si_did_emsg;	/* TRUE when ran out of memory */
+ 
      long	si_compress_cnt;    /* words to add before lowering
  				       compression limit */
      wordnode_T	*si_first_free; /* List of nodes that have been freed during
***************
*** 5477,5497 ****
  	    }
  	    else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2))
  	    {
! 		/* Concatenate this string to previously defined ones, using a
! 		 * slash to separate them. */
! 		l = (int)STRLEN(items[1]) + 1;
! 		if (compflags != NULL)
! 		    l += (int)STRLEN(compflags) + 1;
! 		p = getroom(spin, l, FALSE);
! 		if (p != NULL)
  		{
  		    if (compflags != NULL)
  		    {
! 			STRCPY(p, compflags);
! 			STRCAT(p, "/");
  		    }
- 		    STRCAT(p, items[1]);
- 		    compflags = p;
  		}
  	    }
  	    else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2)
--- 5479,5503 ----
  	    }
  	    else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2))
  	    {
! 		/* Don't use the first rule if it is a number. */
! 		if (compflags != NULL || *skipdigits(items[1]) != NUL)
  		{
+ 		    /* Concatenate this string to previously defined ones,
+ 		     * using a slash to separate them. */
+ 		    l = (int)STRLEN(items[1]) + 1;
  		    if (compflags != NULL)
+ 			l += (int)STRLEN(compflags) + 1;
+ 		    p = getroom(spin, l, FALSE);
+ 		    if (p != NULL)
  		    {
! 			if (compflags != NULL)
! 			{
! 			    STRCPY(p, compflags);
! 			    STRCAT(p, "/");
! 			}
! 			STRCAT(p, items[1]);
! 			compflags = p;
  		    }
  		}
  	    }
  	    else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2)
***************
*** 6291,6297 ****
  
      for (p = compflags; *p != NUL; )
      {
! 	if (vim_strchr((char_u *)"/*+[]", *p) != NULL)
  	    /* Copy non-flag characters directly. */
  	    *tp++ = *p++;
  	else
--- 6297,6303 ----
  
      for (p = compflags; *p != NUL; )
      {
! 	if (vim_strchr((char_u *)"/?*+[]", *p) != NULL)
  	    /* Copy non-flag characters directly. */
  	    *tp++ = *p++;
  	else
***************
*** 6320,6326 ****
  		    {
  			check_renumber(spin);
  			id = spin->si_newcompID--;
! 		    } while (vim_strchr((char_u *)"/+*[]\\-^", id) != NULL);
  		    ci->ci_newID = id;
  		    hash_add(&aff->af_comp, ci->ci_key);
  		}
--- 6326,6332 ----
  		    {
  			check_renumber(spin);
  			id = spin->si_newcompID--;
! 		    } while (vim_strchr((char_u *)"/?*+[]\\-^", id) != NULL);
  		    ci->ci_newID = id;
  		    hash_add(&aff->af_comp, ci->ci_key);
  		}
***************
*** 7364,7373 ****
  
      if (bl == NULL || bl->sb_used + len > SBLOCKSIZE)
      {
! 	/* Allocate a block of memory. This is not freed until much later. */
! 	bl = (sblock_T *)alloc_clear((unsigned)(sizeof(sblock_T) + SBLOCKSIZE));
  	if (bl == NULL)
  	    return NULL;
  	bl->sb_next = spin->si_blocks;
  	spin->si_blocks = bl;
  	bl->sb_used = 0;
--- 7370,7390 ----
  
      if (bl == NULL || bl->sb_used + len > SBLOCKSIZE)
      {
! 	if (len >= SBLOCKSIZE)
! 	    bl = NULL;
! 	else
! 	    /* Allocate a block of memory. It is not freed until much later. */
! 	    bl = (sblock_T *)alloc_clear(
! 				   (unsigned)(sizeof(sblock_T) + SBLOCKSIZE));
  	if (bl == NULL)
+ 	{
+ 	    if (!spin->si_did_emsg)
+ 	    {
+ 		EMSG(_("E845: Insufficient memory, word list will be incomplete"));
+ 		spin->si_did_emsg = TRUE;
+ 	    }
  	    return NULL;
+ 	}
  	bl->sb_next = spin->si_blocks;
  	spin->si_blocks = bl;
  	bl->sb_used = 0;
***************
*** 7382,7387 ****
--- 7399,7405 ----
  
  /*
   * Make a copy of a string into memory allocated with getroom().
+  * Returns NULL when out of memory.
   */
      static char_u *
  getroom_save(spin, s)
***************
*** 7416,7421 ****
--- 7434,7440 ----
  
  /*
   * Allocate the root of a word tree.
+  * Returns NULL when out of memory.
   */
      static wordnode_T *
  wordtree_alloc(spin)
***************
*** 7700,7705 ****
--- 7719,7725 ----
  /*
   * Get a wordnode_T, either from the list of previously freed nodes or
   * allocate a new one.
+  * Returns NULL when out of memory.
   */
      static wordnode_T *
  get_wordnode(spin)
***************
*** 7717,7723 ****
  	--spin->si_free_count;
      }
  #ifdef SPELL_PRINTTREE
!     n->wn_nr = ++spin->si_wordnode_nr;
  #endif
      return n;
  }
--- 7737,7744 ----
  	--spin->si_free_count;
      }
  #ifdef SPELL_PRINTTREE
!     if (n != NULL)
! 	n->wn_nr = ++spin->si_wordnode_nr;
  #endif
      return n;
  }
*** ../vim-7.3.108/src/version.c	2011-02-01 13:48:47.000000000 +0100
--- src/version.c	2011-02-01 13:56:38.000000000 +0100
***************
*** 716,717 ****
--- 716,719 ----
  {   /* Add new patch number below this line */
+ /**/
+     109,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
174. You know what a listserv is.

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///