diff src/spell.c @ 6375:27a36d1013a6 v7.4.519

updated for version 7.4.519 Problem: Crash when using syntax highlighting. Solution: When regprog is freed and replaced, store the result.
author Bram Moolenaar <bram@vim.org>
date Wed, 19 Nov 2014 16:38:07 +0100
parents 0d2c821cdc25
children f28c171348fb
line wrap: on
line diff
--- a/src/spell.c
+++ b/src/spell.c
@@ -1154,11 +1154,14 @@ spell_check(wp, ptr, attrp, capcol, doco
 	    if (capcol != NULL && wp->w_s->b_cap_prog != NULL)
 	    {
 		regmatch_T	regmatch;
+		int		r;
 
 		/* Check for end of sentence. */
 		regmatch.regprog = wp->w_s->b_cap_prog;
 		regmatch.rm_ic = FALSE;
-		if (vim_regexec(&regmatch, ptr, 0))
+		r = vim_regexec(&regmatch, ptr, 0);
+		wp->w_s->b_cap_prog = regmatch.regprog;
+		if (r)
 		    *capcol = (int)(regmatch.endp[0] - ptr);
 	    }
 
@@ -1786,7 +1789,6 @@ can_compound(slang, word, flags)
     char_u	*word;
     char_u	*flags;
 {
-    regmatch_T	regmatch;
 #ifdef FEAT_MBYTE
     char_u	uflags[MAXWLEN * 2];
     int		i;
@@ -1808,9 +1810,7 @@ can_compound(slang, word, flags)
     else
 #endif
 	p = flags;
-    regmatch.regprog = slang->sl_compprog;
-    regmatch.rm_ic = FALSE;
-    if (!vim_regexec(&regmatch, p, 0))
+    if (!vim_regexec_prog(&slang->sl_compprog, FALSE, p, 0))
 	return FALSE;
 
     /* Count the number of syllables.  This may be slow, do it last.  If there
@@ -1930,8 +1930,7 @@ valid_word_prefix(totprefcnt, arridx, fl
 {
     int		prefcnt;
     int		pidx;
-    regprog_T	*rp;
-    regmatch_T	regmatch;
+    regprog_T	**rp;
     int		prefid;
 
     prefid = (unsigned)flags >> 24;
@@ -1950,12 +1949,10 @@ valid_word_prefix(totprefcnt, arridx, fl
 
 	/* Check the condition, if there is one.  The condition index is
 	 * stored in the two bytes above the prefix ID byte.  */
-	rp = slang->sl_prefprog[((unsigned)pidx >> 8) & 0xffff];
-	if (rp != NULL)
-	{
-	    regmatch.regprog = rp;
-	    regmatch.rm_ic = FALSE;
-	    if (!vim_regexec(&regmatch, word, 0))
+	rp = &slang->sl_prefprog[((unsigned)pidx >> 8) & 0xffff];
+	if (*rp != NULL)
+	{
+	    if (!vim_regexec_prog(rp, FALSE, word, 0))
 		continue;
 	}
 	else if (cond_req)
@@ -6903,7 +6900,6 @@ store_aff_word(spin, word, afflist, affi
     hashitem_T	*hi;
     affheader_T	*ah;
     affentry_T	*ae;
-    regmatch_T	regmatch;
     char_u	newword[MAXWLEN];
     int		retval = OK;
     int		i, j;
@@ -6944,15 +6940,14 @@ store_aff_word(spin, word, afflist, affi
 		     * When a previously added affix had CIRCUMFIX this one
 		     * must have it too, if it had not then this one must not
 		     * have one either. */
-		    regmatch.regprog = ae->ae_prog;
-		    regmatch.rm_ic = FALSE;
 		    if ((xht != NULL || !affile->af_pfxpostpone
 				|| ae->ae_chop != NULL
 				|| ae->ae_flags != NULL)
 			    && (ae->ae_chop == NULL
 				|| STRLEN(ae->ae_chop) < wordlen)
 			    && (ae->ae_prog == NULL
-				|| vim_regexec(&regmatch, word, (colnr_T)0))
+				|| vim_regexec_prog(&ae->ae_prog, FALSE,
+							    word, (colnr_T)0))
 			    && (((condit & CONDIT_CFIX) == 0)
 				== ((condit & CONDIT_AFF) == 0
 				    || ae->ae_flags == NULL
@@ -10478,6 +10473,7 @@ check_need_cap(lnum, col)
 		break;
 	    }
 	}
+	curwin->w_s->b_cap_prog = regmatch.regprog;
     }
 
     vim_free(line_copy);