Blame SOURCES/7.4.519

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.519
22c937
Fcc: outbox
22c937
From: Bram Moolenaar <Bram@moolenaar.net>
22c937
Mime-Version: 1.0
22c937
Content-Type: text/plain; charset=UTF-8
22c937
Content-Transfer-Encoding: 8bit
22c937
------------
22c937
22c937
Patch 7.4.519 (after 7.4.497)
22c937
Problem:    Crash when using syntax highlighting.
22c937
Solution:   When regprog is freed and replaced, store the result.
22c937
Files:	    src/buffer.c, src/regexp.c, src/syntax.c, src/spell.c,
22c937
	    src/ex_cmds2.c, src/fileio.c, src/proto/fileio.pro,
22c937
	    src/proto/regexp.pro, src/os_unix.c
22c937
22c937
22c937
*** ../vim-7.4.518/src/buffer.c	2014-09-23 15:45:04.870801055 +0200
22c937
--- src/buffer.c	2014-11-19 15:50:34.129292586 +0100
22c937
***************
22c937
*** 28,36 ****
22c937
  #include "vim.h"
22c937
  
22c937
  #if defined(FEAT_CMDL_COMPL) || defined(FEAT_LISTCMDS) || defined(FEAT_EVAL) || defined(FEAT_PERL)
22c937
! static char_u	*buflist_match __ARGS((regprog_T *prog, buf_T *buf, int ignore_case));
22c937
  # define HAVE_BUFLIST_MATCH
22c937
! static char_u	*fname_match __ARGS((regprog_T *prog, char_u *name, int ignore_case));
22c937
  #endif
22c937
  static void	buflist_setfpos __ARGS((buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, int copy_options));
22c937
  static wininfo_T *find_wininfo __ARGS((buf_T *buf, int skip_diff_buffer));
22c937
--- 28,36 ----
22c937
  #include "vim.h"
22c937
  
22c937
  #if defined(FEAT_CMDL_COMPL) || defined(FEAT_LISTCMDS) || defined(FEAT_EVAL) || defined(FEAT_PERL)
22c937
! static char_u	*buflist_match __ARGS((regmatch_T *rmp, buf_T *buf, int ignore_case));
22c937
  # define HAVE_BUFLIST_MATCH
22c937
! static char_u	*fname_match __ARGS((regmatch_T *rmp, char_u *name, int ignore_case));
22c937
  #endif
22c937
  static void	buflist_setfpos __ARGS((buf_T *buf, win_T *win, linenr_T lnum, colnr_T col, int copy_options));
22c937
  static wininfo_T *find_wininfo __ARGS((buf_T *buf, int skip_diff_buffer));
22c937
***************
22c937
*** 2220,2226 ****
22c937
      int		curtab_only;	/* find buffers in current tab only */
22c937
  {
22c937
      buf_T	*buf;
22c937
-     regprog_T	*prog;
22c937
      int		match = -1;
22c937
      int		find_listed;
22c937
      char_u	*pat;
22c937
--- 2220,2225 ----
22c937
***************
22c937
*** 2265,2278 ****
22c937
  	{
22c937
  	    for (attempt = 0; attempt <= 3; ++attempt)
22c937
  	    {
22c937
  		/* may add '^' and '$' */
22c937
  		if (toggledollar)
22c937
  		    *patend = (attempt < 2) ? NUL : '$'; /* add/remove '$' */
22c937
  		p = pat;
22c937
  		if (*p == '^' && !(attempt & 1))	 /* add/remove '^' */
22c937
  		    ++p;
22c937
! 		prog = vim_regcomp(p, p_magic ? RE_MAGIC : 0);
22c937
! 		if (prog == NULL)
22c937
  		{
22c937
  		    vim_free(pat);
22c937
  		    return -1;
22c937
--- 2264,2279 ----
22c937
  	{
22c937
  	    for (attempt = 0; attempt <= 3; ++attempt)
22c937
  	    {
22c937
+ 		regmatch_T	regmatch;
22c937
+ 
22c937
  		/* may add '^' and '$' */
22c937
  		if (toggledollar)
22c937
  		    *patend = (attempt < 2) ? NUL : '$'; /* add/remove '$' */
22c937
  		p = pat;
22c937
  		if (*p == '^' && !(attempt & 1))	 /* add/remove '^' */
22c937
  		    ++p;
22c937
! 		regmatch.regprog = vim_regcomp(p, p_magic ? RE_MAGIC : 0);
22c937
! 		if (regmatch.regprog == NULL)
22c937
  		{
22c937
  		    vim_free(pat);
22c937
  		    return -1;
22c937
***************
22c937
*** 2283,2289 ****
22c937
  #ifdef FEAT_DIFF
22c937
  			    && (!diffmode || diff_mode_buf(buf))
22c937
  #endif
22c937
! 			    && buflist_match(prog, buf, FALSE) != NULL)
22c937
  		    {
22c937
  			if (curtab_only)
22c937
  			{
22c937
--- 2284,2290 ----
22c937
  #ifdef FEAT_DIFF
22c937
  			    && (!diffmode || diff_mode_buf(buf))
22c937
  #endif
22c937
! 			    && buflist_match(&regmatch, buf, FALSE) != NULL)
22c937
  		    {
22c937
  			if (curtab_only)
22c937
  			{
22c937
***************
22c937
*** 2310,2316 ****
22c937
  			match = buf->b_fnum;	/* remember first match */
22c937
  		    }
22c937
  
22c937
! 		vim_regfree(prog);
22c937
  		if (match >= 0)			/* found one match */
22c937
  		    break;
22c937
  	    }
22c937
--- 2311,2317 ----
22c937
  			match = buf->b_fnum;	/* remember first match */
22c937
  		    }
22c937
  
22c937
! 		vim_regfree(regmatch.regprog);
22c937
  		if (match >= 0)			/* found one match */
22c937
  		    break;
22c937
  	    }
22c937
***************
22c937
*** 2352,2358 ****
22c937
      int		round;
22c937
      char_u	*p;
22c937
      int		attempt;
22c937
-     regprog_T	*prog;
22c937
      char_u	*patc;
22c937
  
22c937
      *num_file = 0;		    /* return values in case of FAIL */
22c937
--- 2353,2358 ----
22c937
***************
22c937
*** 2376,2385 ****
22c937
       */
22c937
      for (attempt = 0; attempt <= 1; ++attempt)
22c937
      {
22c937
  	if (attempt > 0 && patc == pat)
22c937
  	    break;	/* there was no anchor, no need to try again */
22c937
! 	prog = vim_regcomp(patc + attempt * 11, RE_MAGIC);
22c937
! 	if (prog == NULL)
22c937
  	{
22c937
  	    if (patc != pat)
22c937
  		vim_free(patc);
22c937
--- 2376,2387 ----
22c937
       */
22c937
      for (attempt = 0; attempt <= 1; ++attempt)
22c937
      {
22c937
+ 	regmatch_T	regmatch;
22c937
+ 
22c937
  	if (attempt > 0 && patc == pat)
22c937
  	    break;	/* there was no anchor, no need to try again */
22c937
! 	regmatch.regprog = vim_regcomp(patc + attempt * 11, RE_MAGIC);
22c937
! 	if (regmatch.regprog == NULL)
22c937
  	{
22c937
  	    if (patc != pat)
22c937
  		vim_free(patc);
22c937
***************
22c937
*** 2397,2403 ****
22c937
  	    {
22c937
  		if (!buf->b_p_bl)	/* skip unlisted buffers */
22c937
  		    continue;
22c937
! 		p = buflist_match(prog, buf, p_wic);
22c937
  		if (p != NULL)
22c937
  		{
22c937
  		    if (round == 1)
22c937
--- 2399,2405 ----
22c937
  	    {
22c937
  		if (!buf->b_p_bl)	/* skip unlisted buffers */
22c937
  		    continue;
22c937
! 		p = buflist_match(&regmatch, buf, p_wic);
22c937
  		if (p != NULL)
22c937
  		{
22c937
  		    if (round == 1)
22c937
***************
22c937
*** 2419,2432 ****
22c937
  		*file = (char_u **)alloc((unsigned)(count * sizeof(char_u *)));
22c937
  		if (*file == NULL)
22c937
  		{
22c937
! 		    vim_regfree(prog);
22c937
  		    if (patc != pat)
22c937
  			vim_free(patc);
22c937
  		    return FAIL;
22c937
  		}
22c937
  	    }
22c937
  	}
22c937
! 	vim_regfree(prog);
22c937
  	if (count)		/* match(es) found, break here */
22c937
  	    break;
22c937
      }
22c937
--- 2421,2434 ----
22c937
  		*file = (char_u **)alloc((unsigned)(count * sizeof(char_u *)));
22c937
  		if (*file == NULL)
22c937
  		{
22c937
! 		    vim_regfree(regmatch.regprog);
22c937
  		    if (patc != pat)
22c937
  			vim_free(patc);
22c937
  		    return FAIL;
22c937
  		}
22c937
  	    }
22c937
  	}
22c937
! 	vim_regfree(regmatch.regprog);
22c937
  	if (count)		/* match(es) found, break here */
22c937
  	    break;
22c937
      }
22c937
***************
22c937
*** 2445,2461 ****
22c937
   * Check for a match on the file name for buffer "buf" with regprog "prog".
22c937
   */
22c937
      static char_u *
22c937
! buflist_match(prog, buf, ignore_case)
22c937
!     regprog_T	*prog;
22c937
      buf_T	*buf;
22c937
      int		ignore_case;  /* when TRUE ignore case, when FALSE use 'fic' */
22c937
  {
22c937
      char_u	*match;
22c937
  
22c937
      /* First try the short file name, then the long file name. */
22c937
!     match = fname_match(prog, buf->b_sfname, ignore_case);
22c937
      if (match == NULL)
22c937
! 	match = fname_match(prog, buf->b_ffname, ignore_case);
22c937
  
22c937
      return match;
22c937
  }
22c937
--- 2447,2463 ----
22c937
   * Check for a match on the file name for buffer "buf" with regprog "prog".
22c937
   */
22c937
      static char_u *
22c937
! buflist_match(rmp, buf, ignore_case)
22c937
!     regmatch_T	*rmp;
22c937
      buf_T	*buf;
22c937
      int		ignore_case;  /* when TRUE ignore case, when FALSE use 'fic' */
22c937
  {
22c937
      char_u	*match;
22c937
  
22c937
      /* First try the short file name, then the long file name. */
22c937
!     match = fname_match(rmp, buf->b_sfname, ignore_case);
22c937
      if (match == NULL)
22c937
! 	match = fname_match(rmp, buf->b_ffname, ignore_case);
22c937
  
22c937
      return match;
22c937
  }
22c937
***************
22c937
*** 2465,2491 ****
22c937
   * Return "name" when there is a match, NULL when not.
22c937
   */
22c937
      static char_u *
22c937
! fname_match(prog, name, ignore_case)
22c937
!     regprog_T	*prog;
22c937
      char_u	*name;
22c937
      int		ignore_case;  /* when TRUE ignore case, when FALSE use 'fic' */
22c937
  {
22c937
      char_u	*match = NULL;
22c937
      char_u	*p;
22c937
-     regmatch_T	regmatch;
22c937
  
22c937
      if (name != NULL)
22c937
      {
22c937
- 	regmatch.regprog = prog;
22c937
  	/* Ignore case when 'fileignorecase' or the argument is set. */
22c937
! 	regmatch.rm_ic = p_fic || ignore_case;
22c937
! 	if (vim_regexec(&regmatch, name, (colnr_T)0))
22c937
  	    match = name;
22c937
  	else
22c937
  	{
22c937
  	    /* Replace $(HOME) with '~' and try matching again. */
22c937
  	    p = home_replace_save(NULL, name);
22c937
! 	    if (p != NULL && vim_regexec(&regmatch, p, (colnr_T)0))
22c937
  		match = name;
22c937
  	    vim_free(p);
22c937
  	}
22c937
--- 2467,2491 ----
22c937
   * Return "name" when there is a match, NULL when not.
22c937
   */
22c937
      static char_u *
22c937
! fname_match(rmp, name, ignore_case)
22c937
!     regmatch_T	*rmp;
22c937
      char_u	*name;
22c937
      int		ignore_case;  /* when TRUE ignore case, when FALSE use 'fic' */
22c937
  {
22c937
      char_u	*match = NULL;
22c937
      char_u	*p;
22c937
  
22c937
      if (name != NULL)
22c937
      {
22c937
  	/* Ignore case when 'fileignorecase' or the argument is set. */
22c937
! 	rmp->rm_ic = p_fic || ignore_case;
22c937
! 	if (vim_regexec(rmp, name, (colnr_T)0))
22c937
  	    match = name;
22c937
  	else
22c937
  	{
22c937
  	    /* Replace $(HOME) with '~' and try matching again. */
22c937
  	    p = home_replace_save(NULL, name);
22c937
! 	    if (p != NULL && vim_regexec(rmp, p, (colnr_T)0))
22c937
  		match = name;
22c937
  	    vim_free(p);
22c937
  	}
22c937
*** ../vim-7.4.518/src/regexp.c	2014-11-05 14:26:30.760758363 +0100
22c937
--- src/regexp.c	2014-11-19 16:10:43.203390451 +0100
22c937
***************
22c937
*** 8163,8168 ****
22c937
--- 8163,8169 ----
22c937
  /*
22c937
   * Match a regexp against a string.
22c937
   * "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
22c937
+  * Note: "rmp->regprog" may be freed and changed.
22c937
   * Uses curbuf for line count and 'iskeyword'.
22c937
   * When "nl" is TRUE consider a "\n" in "line" to be a line break.
22c937
   *
22c937
***************
22c937
*** 8203,8208 ****
22c937
--- 8204,8232 ----
22c937
      return result;
22c937
  }
22c937
  
22c937
+ /*
22c937
+  * Note: "*prog" may be freed and changed.
22c937
+  */
22c937
+     int
22c937
+ vim_regexec_prog(prog, ignore_case, line, col)
22c937
+     regprog_T	**prog;
22c937
+     int		ignore_case;
22c937
+     char_u	*line;
22c937
+     colnr_T	col;
22c937
+ {
22c937
+     int r;
22c937
+     regmatch_T regmatch;
22c937
+ 
22c937
+     regmatch.regprog = *prog;
22c937
+     regmatch.rm_ic = ignore_case;
22c937
+     r = vim_regexec_both(&regmatch, line, col, FALSE);
22c937
+     *prog = regmatch.regprog;
22c937
+     return r;
22c937
+ }
22c937
+ 
22c937
+ /*
22c937
+  * Note: "rmp->regprog" may be freed and changed.
22c937
+  */
22c937
      int
22c937
  vim_regexec(rmp, line, col)
22c937
      regmatch_T	*rmp;
22c937
***************
22c937
*** 8216,8221 ****
22c937
--- 8240,8246 ----
22c937
  	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
22c937
  /*
22c937
   * Like vim_regexec(), but consider a "\n" in "line" to be a line break.
22c937
+  * Note: "rmp->regprog" may be freed and changed.
22c937
   */
22c937
      int
22c937
  vim_regexec_nl(rmp, line, col)
22c937
***************
22c937
*** 8230,8235 ****
22c937
--- 8255,8261 ----
22c937
  /*
22c937
   * Match a regexp against multiple lines.
22c937
   * "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
22c937
+  * Note: "rmp->regprog" may be freed and changed.
22c937
   * Uses curbuf for line count and 'iskeyword'.
22c937
   *
22c937
   * Return zero if there is no match.  Return number of lines contained in the
22c937
*** ../vim-7.4.518/src/syntax.c	2014-06-12 12:20:50.191541385 +0200
22c937
--- src/syntax.c	2014-11-19 15:39:08.493182536 +0100
22c937
***************
22c937
*** 992,1004 ****
22c937
      linenr_T	lnum;
22c937
  {
22c937
      regmmatch_T regmatch;
22c937
  
22c937
      if (syn_block->b_syn_linecont_prog != NULL)
22c937
      {
22c937
  	regmatch.rmm_ic = syn_block->b_syn_linecont_ic;
22c937
  	regmatch.regprog = syn_block->b_syn_linecont_prog;
22c937
! 	return syn_regexec(&regmatch, lnum, (colnr_T)0,
22c937
  				IF_SYN_TIME(&syn_block->b_syn_linecont_time));
22c937
      }
22c937
      return FALSE;
22c937
  }
22c937
--- 992,1007 ----
22c937
      linenr_T	lnum;
22c937
  {
22c937
      regmmatch_T regmatch;
22c937
+     int r;
22c937
  
22c937
      if (syn_block->b_syn_linecont_prog != NULL)
22c937
      {
22c937
  	regmatch.rmm_ic = syn_block->b_syn_linecont_ic;
22c937
  	regmatch.regprog = syn_block->b_syn_linecont_prog;
22c937
! 	r = syn_regexec(&regmatch, lnum, (colnr_T)0,
22c937
  				IF_SYN_TIME(&syn_block->b_syn_linecont_time));
22c937
+ 	syn_block->b_syn_linecont_prog = regmatch.regprog;
22c937
+ 	return r;
22c937
      }
22c937
      return FALSE;
22c937
  }
22c937
***************
22c937
*** 2075,2080 ****
22c937
--- 2078,2085 ----
22c937
  					    cur_si->si_cont_list, &spp->sp_syn,
22c937
  					    spp->sp_flags & HL_CONTAINED))))
22c937
  			{
22c937
+ 			    int r;
22c937
+ 
22c937
  			    /* If we already tried matching in this line, and
22c937
  			     * there isn't a match before next_match_col, skip
22c937
  			     * this item. */
22c937
***************
22c937
*** 2089,2098 ****
22c937
  
22c937
  			    regmatch.rmm_ic = spp->sp_ic;
22c937
  			    regmatch.regprog = spp->sp_prog;
22c937
! 			    if (!syn_regexec(&regmatch,
22c937
  					     current_lnum,
22c937
  					     (colnr_T)lc_col,
22c937
! 				             IF_SYN_TIME(&spp->sp_time)))
22c937
  			    {
22c937
  				/* no match in this line, try another one */
22c937
  				spp->sp_startcol = MAXCOL;
22c937
--- 2094,2105 ----
22c937
  
22c937
  			    regmatch.rmm_ic = spp->sp_ic;
22c937
  			    regmatch.regprog = spp->sp_prog;
22c937
! 			    r = syn_regexec(&regmatch,
22c937
  					     current_lnum,
22c937
  					     (colnr_T)lc_col,
22c937
! 				             IF_SYN_TIME(&spp->sp_time));
22c937
! 			    spp->sp_prog = regmatch.regprog;
22c937
! 			    if (!r)
22c937
  			    {
22c937
  				/* no match in this line, try another one */
22c937
  				spp->sp_startcol = MAXCOL;
22c937
***************
22c937
*** 2963,2968 ****
22c937
--- 2970,2976 ----
22c937
  	for (idx = start_idx; idx < syn_block->b_syn_patterns.ga_len; ++idx)
22c937
  	{
22c937
  	    int lc_col = matchcol;
22c937
+ 	    int r;
22c937
  
22c937
  	    spp = &(SYN_ITEMS(syn_block)[idx]);
22c937
  	    if (spp->sp_type != SPTYPE_END)	/* past last END pattern */
22c937
***************
22c937
*** 2973,2980 ****
22c937
  
22c937
  	    regmatch.rmm_ic = spp->sp_ic;
22c937
  	    regmatch.regprog = spp->sp_prog;
22c937
! 	    if (syn_regexec(&regmatch, startpos->lnum, lc_col,
22c937
! 						  IF_SYN_TIME(&spp->sp_time)))
22c937
  	    {
22c937
  		if (best_idx == -1 || regmatch.startpos[0].col
22c937
  					      < best_regmatch.startpos[0].col)
22c937
--- 2981,2990 ----
22c937
  
22c937
  	    regmatch.rmm_ic = spp->sp_ic;
22c937
  	    regmatch.regprog = spp->sp_prog;
22c937
! 	    r = syn_regexec(&regmatch, startpos->lnum, lc_col,
22c937
! 						  IF_SYN_TIME(&spp->sp_time));
22c937
! 	    spp->sp_prog = regmatch.regprog;
22c937
! 	    if (r)
22c937
  	    {
22c937
  		if (best_idx == -1 || regmatch.startpos[0].col
22c937
  					      < best_regmatch.startpos[0].col)
22c937
***************
22c937
*** 3000,3013 ****
22c937
  	if (spp_skip != NULL)
22c937
  	{
22c937
  	    int lc_col = matchcol - spp_skip->sp_offsets[SPO_LC_OFF];
22c937
  
22c937
  	    if (lc_col < 0)
22c937
  		lc_col = 0;
22c937
  	    regmatch.rmm_ic = spp_skip->sp_ic;
22c937
  	    regmatch.regprog = spp_skip->sp_prog;
22c937
! 	    if (syn_regexec(&regmatch, startpos->lnum, lc_col,
22c937
! 					      IF_SYN_TIME(&spp_skip->sp_time))
22c937
! 		    && regmatch.startpos[0].col
22c937
  					     <= best_regmatch.startpos[0].col)
22c937
  	    {
22c937
  		/* Add offset to skip pattern match */
22c937
--- 3010,3025 ----
22c937
  	if (spp_skip != NULL)
22c937
  	{
22c937
  	    int lc_col = matchcol - spp_skip->sp_offsets[SPO_LC_OFF];
22c937
+ 	    int r;
22c937
  
22c937
  	    if (lc_col < 0)
22c937
  		lc_col = 0;
22c937
  	    regmatch.rmm_ic = spp_skip->sp_ic;
22c937
  	    regmatch.regprog = spp_skip->sp_prog;
22c937
! 	    r = syn_regexec(&regmatch, startpos->lnum, lc_col,
22c937
! 					      IF_SYN_TIME(&spp_skip->sp_time));
22c937
! 	    spp_skip->sp_prog = regmatch.regprog;
22c937
! 	    if (r && regmatch.startpos[0].col
22c937
  					     <= best_regmatch.startpos[0].col)
22c937
  	    {
22c937
  		/* Add offset to skip pattern match */
22c937
*** ../vim-7.4.518/src/spell.c	2014-09-19 16:04:08.050417797 +0200
22c937
--- src/spell.c	2014-11-19 16:28:49.798964748 +0100
22c937
***************
22c937
*** 1154,1164 ****
22c937
  	    if (capcol != NULL && wp->w_s->b_cap_prog != NULL)
22c937
  	    {
22c937
  		regmatch_T	regmatch;
22c937
  
22c937
  		/* Check for end of sentence. */
22c937
  		regmatch.regprog = wp->w_s->b_cap_prog;
22c937
  		regmatch.rm_ic = FALSE;
22c937
! 		if (vim_regexec(&regmatch, ptr, 0))
22c937
  		    *capcol = (int)(regmatch.endp[0] - ptr);
22c937
  	    }
22c937
  
22c937
--- 1154,1167 ----
22c937
  	    if (capcol != NULL && wp->w_s->b_cap_prog != NULL)
22c937
  	    {
22c937
  		regmatch_T	regmatch;
22c937
+ 		int		r;
22c937
  
22c937
  		/* Check for end of sentence. */
22c937
  		regmatch.regprog = wp->w_s->b_cap_prog;
22c937
  		regmatch.rm_ic = FALSE;
22c937
! 		r = vim_regexec(&regmatch, ptr, 0);
22c937
! 		wp->w_s->b_cap_prog = regmatch.regprog;
22c937
! 		if (r)
22c937
  		    *capcol = (int)(regmatch.endp[0] - ptr);
22c937
  	    }
22c937
  
22c937
***************
22c937
*** 1786,1792 ****
22c937
      char_u	*word;
22c937
      char_u	*flags;
22c937
  {
22c937
-     regmatch_T	regmatch;
22c937
  #ifdef FEAT_MBYTE
22c937
      char_u	uflags[MAXWLEN * 2];
22c937
      int		i;
22c937
--- 1789,1794 ----
22c937
***************
22c937
*** 1808,1816 ****
22c937
      else
22c937
  #endif
22c937
  	p = flags;
22c937
!     regmatch.regprog = slang->sl_compprog;
22c937
!     regmatch.rm_ic = FALSE;
22c937
!     if (!vim_regexec(&regmatch, p, 0))
22c937
  	return FALSE;
22c937
  
22c937
      /* Count the number of syllables.  This may be slow, do it last.  If there
22c937
--- 1810,1816 ----
22c937
      else
22c937
  #endif
22c937
  	p = flags;
22c937
!     if (!vim_regexec_prog(&slang->sl_compprog, FALSE, p, 0))
22c937
  	return FALSE;
22c937
  
22c937
      /* Count the number of syllables.  This may be slow, do it last.  If there
22c937
***************
22c937
*** 1930,1937 ****
22c937
  {
22c937
      int		prefcnt;
22c937
      int		pidx;
22c937
!     regprog_T	*rp;
22c937
!     regmatch_T	regmatch;
22c937
      int		prefid;
22c937
  
22c937
      prefid = (unsigned)flags >> 24;
22c937
--- 1930,1936 ----
22c937
  {
22c937
      int		prefcnt;
22c937
      int		pidx;
22c937
!     regprog_T	**rp;
22c937
      int		prefid;
22c937
  
22c937
      prefid = (unsigned)flags >> 24;
22c937
***************
22c937
*** 1950,1961 ****
22c937
  
22c937
  	/* Check the condition, if there is one.  The condition index is
22c937
  	 * stored in the two bytes above the prefix ID byte.  */
22c937
! 	rp = slang->sl_prefprog[((unsigned)pidx >> 8) & 0xffff];
22c937
! 	if (rp != NULL)
22c937
  	{
22c937
! 	    regmatch.regprog = rp;
22c937
! 	    regmatch.rm_ic = FALSE;
22c937
! 	    if (!vim_regexec(&regmatch, word, 0))
22c937
  		continue;
22c937
  	}
22c937
  	else if (cond_req)
22c937
--- 1949,1958 ----
22c937
  
22c937
  	/* Check the condition, if there is one.  The condition index is
22c937
  	 * stored in the two bytes above the prefix ID byte.  */
22c937
! 	rp = &slang->sl_prefprog[((unsigned)pidx >> 8) & 0xffff];
22c937
! 	if (*rp != NULL)
22c937
  	{
22c937
! 	    if (!vim_regexec_prog(rp, FALSE, word, 0))
22c937
  		continue;
22c937
  	}
22c937
  	else if (cond_req)
22c937
***************
22c937
*** 6903,6909 ****
22c937
      hashitem_T	*hi;
22c937
      affheader_T	*ah;
22c937
      affentry_T	*ae;
22c937
-     regmatch_T	regmatch;
22c937
      char_u	newword[MAXWLEN];
22c937
      int		retval = OK;
22c937
      int		i, j;
22c937
--- 6900,6905 ----
22c937
***************
22c937
*** 6944,6958 ****
22c937
  		     * When a previously added affix had CIRCUMFIX this one
22c937
  		     * must have it too, if it had not then this one must not
22c937
  		     * have one either. */
22c937
- 		    regmatch.regprog = ae->ae_prog;
22c937
- 		    regmatch.rm_ic = FALSE;
22c937
  		    if ((xht != NULL || !affile->af_pfxpostpone
22c937
  				|| ae->ae_chop != NULL
22c937
  				|| ae->ae_flags != NULL)
22c937
  			    && (ae->ae_chop == NULL
22c937
  				|| STRLEN(ae->ae_chop) < wordlen)
22c937
  			    && (ae->ae_prog == NULL
22c937
! 				|| vim_regexec(&regmatch, word, (colnr_T)0))
22c937
  			    && (((condit & CONDIT_CFIX) == 0)
22c937
  				== ((condit & CONDIT_AFF) == 0
22c937
  				    || ae->ae_flags == NULL
22c937
--- 6940,6953 ----
22c937
  		     * When a previously added affix had CIRCUMFIX this one
22c937
  		     * must have it too, if it had not then this one must not
22c937
  		     * have one either. */
22c937
  		    if ((xht != NULL || !affile->af_pfxpostpone
22c937
  				|| ae->ae_chop != NULL
22c937
  				|| ae->ae_flags != NULL)
22c937
  			    && (ae->ae_chop == NULL
22c937
  				|| STRLEN(ae->ae_chop) < wordlen)
22c937
  			    && (ae->ae_prog == NULL
22c937
! 				|| vim_regexec_prog(&ae->ae_prog, FALSE,
22c937
! 							    word, (colnr_T)0))
22c937
  			    && (((condit & CONDIT_CFIX) == 0)
22c937
  				== ((condit & CONDIT_AFF) == 0
22c937
  				    || ae->ae_flags == NULL
22c937
***************
22c937
*** 10478,10483 ****
22c937
--- 10473,10479 ----
22c937
  		break;
22c937
  	    }
22c937
  	}
22c937
+ 	curwin->w_s->b_cap_prog = regmatch.regprog;
22c937
      }
22c937
  
22c937
      vim_free(line_copy);
22c937
*** ../vim-7.4.518/src/ex_cmds2.c	2014-08-06 18:17:03.471147780 +0200
22c937
--- src/ex_cmds2.c	2014-11-19 16:24:22.162013396 +0100
22c937
***************
22c937
*** 739,745 ****
22c937
      struct debuggy *bp;
22c937
      int		i;
22c937
      linenr_T	lnum = 0;
22c937
-     regmatch_T	regmatch;
22c937
      char_u	*name = fname;
22c937
      int		prev_got_int;
22c937
  
22c937
--- 739,744 ----
22c937
***************
22c937
*** 771,778 ****
22c937
  #endif
22c937
  		(bp->dbg_lnum > after && (lnum == 0 || bp->dbg_lnum < lnum)))))
22c937
  	{
22c937
- 	    regmatch.regprog = bp->dbg_prog;
22c937
- 	    regmatch.rm_ic = FALSE;
22c937
  	    /*
22c937
  	     * Save the value of got_int and reset it.  We don't want a
22c937
  	     * previous interruption cancel matching, only hitting CTRL-C
22c937
--- 770,775 ----
22c937
***************
22c937
*** 780,786 ****
22c937
  	     */
22c937
  	    prev_got_int = got_int;
22c937
  	    got_int = FALSE;
22c937
! 	    if (vim_regexec(&regmatch, name, (colnr_T)0))
22c937
  	    {
22c937
  		lnum = bp->dbg_lnum;
22c937
  		if (fp != NULL)
22c937
--- 777,783 ----
22c937
  	     */
22c937
  	    prev_got_int = got_int;
22c937
  	    got_int = FALSE;
22c937
! 	    if (vim_regexec_prog(&bp->dbg_prog, FALSE, name, (colnr_T)0))
22c937
  	    {
22c937
  		lnum = bp->dbg_lnum;
22c937
  		if (fp != NULL)
22c937
*** ../vim-7.4.518/src/fileio.c	2014-11-12 15:15:34.983882077 +0100
22c937
--- src/fileio.c	2014-11-19 15:57:01.496837984 +0100
22c937
***************
22c937
*** 7772,7777 ****
22c937
--- 7772,7780 ----
22c937
  static int do_autocmd_event __ARGS((event_T event, char_u *pat, int nested, char_u *cmd, int forceit, int group));
22c937
  static int apply_autocmds_group __ARGS((event_T event, char_u *fname, char_u *fname_io, int force, int group, buf_T *buf, exarg_T *eap));
22c937
  static void auto_next_pat __ARGS((AutoPatCmd *apc, int stop_at_last));
22c937
+ #if defined(FEAT_AUTOCMD) || defined(FEAT_WILDIGN)
22c937
+ static int match_file_pat __ARGS((char_u *pattern, regprog_T **prog, char_u *fname, char_u *sfname, char_u *tail, int allow_dirs));
22c937
+ #endif
22c937
  
22c937
  
22c937
  static event_T	last_event;
22c937
***************
22c937
*** 9640,9646 ****
22c937
  	{
22c937
  	    /* execution-condition */
22c937
  	    if (ap->buflocal_nr == 0
22c937
! 		    ? (match_file_pat(NULL, ap->reg_prog, apc->fname,
22c937
  				      apc->sfname, apc->tail, ap->allow_dirs))
22c937
  		    : ap->buflocal_nr == apc->arg_bufnr)
22c937
  	    {
22c937
--- 9643,9649 ----
22c937
  	{
22c937
  	    /* execution-condition */
22c937
  	    if (ap->buflocal_nr == 0
22c937
! 		    ? (match_file_pat(NULL, &ap->reg_prog, apc->fname,
22c937
  				      apc->sfname, apc->tail, ap->allow_dirs))
22c937
  		    : ap->buflocal_nr == apc->arg_bufnr)
22c937
  	    {
22c937
***************
22c937
*** 9774,9780 ****
22c937
      for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next)
22c937
  	if (ap->pat != NULL && ap->cmds != NULL
22c937
  	      && (ap->buflocal_nr == 0
22c937
! 		? match_file_pat(NULL, ap->reg_prog,
22c937
  					  fname, sfname, tail, ap->allow_dirs)
22c937
  		: buf != NULL && ap->buflocal_nr == buf->b_fnum
22c937
  	   ))
22c937
--- 9777,9783 ----
22c937
      for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next)
22c937
  	if (ap->pat != NULL && ap->cmds != NULL
22c937
  	      && (ap->buflocal_nr == 0
22c937
! 		? match_file_pat(NULL, &ap->reg_prog,
22c937
  					  fname, sfname, tail, ap->allow_dirs)
22c937
  		: buf != NULL && ap->buflocal_nr == buf->b_fnum
22c937
  	   ))
22c937
***************
22c937
*** 10035,10044 ****
22c937
   * Used for autocommands and 'wildignore'.
22c937
   * Returns TRUE if there is a match, FALSE otherwise.
22c937
   */
22c937
!     int
22c937
  match_file_pat(pattern, prog, fname, sfname, tail, allow_dirs)
22c937
      char_u	*pattern;		/* pattern to match with */
22c937
!     regprog_T	*prog;			/* pre-compiled regprog or NULL */
22c937
      char_u	*fname;			/* full path of file name */
22c937
      char_u	*sfname;		/* short file name or NULL */
22c937
      char_u	*tail;			/* tail of path */
22c937
--- 10038,10047 ----
22c937
   * Used for autocommands and 'wildignore'.
22c937
   * Returns TRUE if there is a match, FALSE otherwise.
22c937
   */
22c937
!     static int
22c937
  match_file_pat(pattern, prog, fname, sfname, tail, allow_dirs)
22c937
      char_u	*pattern;		/* pattern to match with */
22c937
!     regprog_T	**prog;			/* pre-compiled regprog or NULL */
22c937
      char_u	*fname;			/* full path of file name */
22c937
      char_u	*sfname;		/* short file name or NULL */
22c937
      char_u	*tail;			/* tail of path */
22c937
***************
22c937
*** 10093,10099 ****
22c937
  #endif
22c937
      {
22c937
  	if (prog != NULL)
22c937
! 	    regmatch.regprog = prog;
22c937
  	else
22c937
  	    regmatch.regprog = vim_regcomp(pattern, RE_MAGIC);
22c937
      }
22c937
--- 10096,10102 ----
22c937
  #endif
22c937
      {
22c937
  	if (prog != NULL)
22c937
! 	    regmatch.regprog = *prog;
22c937
  	else
22c937
  	    regmatch.regprog = vim_regcomp(pattern, RE_MAGIC);
22c937
      }
22c937
***************
22c937
*** 10119,10125 ****
22c937
  		 || (!allow_dirs && vim_regexec(&regmatch, tail, (colnr_T)0)))))
22c937
  	result = TRUE;
22c937
  
22c937
!     if (prog == NULL)
22c937
  	vim_regfree(regmatch.regprog);
22c937
      return result;
22c937
  }
22c937
--- 10122,10130 ----
22c937
  		 || (!allow_dirs && vim_regexec(&regmatch, tail, (colnr_T)0)))))
22c937
  	result = TRUE;
22c937
  
22c937
!     if (prog != NULL)
22c937
! 	*prog = regmatch.regprog;
22c937
!     else
22c937
  	vim_regfree(regmatch.regprog);
22c937
      return result;
22c937
  }
22c937
*** ../vim-7.4.518/src/proto/fileio.pro	2014-08-22 23:05:50.106606614 +0200
22c937
--- src/proto/fileio.pro	2014-11-19 15:55:55.013602515 +0100
22c937
***************
22c937
*** 59,65 ****
22c937
  char_u *get_event_name __ARGS((expand_T *xp, int idx));
22c937
  int autocmd_supported __ARGS((char_u *name));
22c937
  int au_exists __ARGS((char_u *arg));
22c937
- int match_file_pat __ARGS((char_u *pattern, regprog_T *prog, char_u *fname, char_u *sfname, char_u *tail, int allow_dirs));
22c937
  int match_file_list __ARGS((char_u *list, char_u *sfname, char_u *ffname));
22c937
  char_u *file_pat_to_reg_pat __ARGS((char_u *pat, char_u *pat_end, char *allow_dirs, int no_bslash));
22c937
  long read_eintr __ARGS((int fd, void *buf, size_t bufsize));
22c937
--- 59,64 ----
22c937
*** ../vim-7.4.518/src/proto/regexp.pro	2014-04-02 19:00:53.043644100 +0200
22c937
--- src/proto/regexp.pro	2014-11-19 16:11:34.522800480 +0100
22c937
***************
22c937
*** 13,18 ****
22c937
--- 13,19 ----
22c937
  list_T *reg_submatch_list __ARGS((int no));
22c937
  regprog_T *vim_regcomp __ARGS((char_u *expr_arg, int re_flags));
22c937
  void vim_regfree __ARGS((regprog_T *prog));
22c937
+ int vim_regexec_prog __ARGS((regprog_T **prog, int ignore_case, char_u *line, colnr_T col));
22c937
  int vim_regexec __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
22c937
  int vim_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
22c937
  long vim_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
22c937
*** ../vim-7.4.518/src/os_unix.c	2014-10-11 14:47:22.829275547 +0200
22c937
--- src/os_unix.c	2014-11-19 16:26:48.504346537 +0100
22c937
***************
22c937
*** 1610,1617 ****
22c937
      static int
22c937
  x_connect_to_server()
22c937
  {
22c937
-     regmatch_T	regmatch;
22c937
- 
22c937
  #if defined(FEAT_CLIENTSERVER)
22c937
      if (x_force_connect)
22c937
  	return TRUE;
22c937
--- 1610,1615 ----
22c937
***************
22c937
*** 1622,1630 ****
22c937
      /* Check for a match with "exclude:" from 'clipboard'. */
22c937
      if (clip_exclude_prog != NULL)
22c937
      {
22c937
! 	regmatch.rm_ic = FALSE;		/* Don't ignore case */
22c937
! 	regmatch.regprog = clip_exclude_prog;
22c937
! 	if (vim_regexec(&regmatch, T_NAME, (colnr_T)0))
22c937
  	    return FALSE;
22c937
      }
22c937
      return TRUE;
22c937
--- 1620,1626 ----
22c937
      /* Check for a match with "exclude:" from 'clipboard'. */
22c937
      if (clip_exclude_prog != NULL)
22c937
      {
22c937
! 	if (vim_regexec_prog(&clip_exclude_prog, FALSE, T_NAME, (colnr_T)0))
22c937
  	    return FALSE;
22c937
      }
22c937
      return TRUE;
22c937
*** ../vim-7.4.518/src/version.c	2014-11-19 13:40:04.903715962 +0100
22c937
--- src/version.c	2014-11-19 15:22:36.464620036 +0100
22c937
***************
22c937
*** 743,744 ****
22c937
--- 743,746 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     519,
22c937
  /**/
22c937
22c937
-- 
22c937
BRIDGEKEEPER: What is your favorite editor?
22c937
GAWAIN:       Emacs ...  No, Viiiiiiiiiiimmmmmmm!
22c937
           "Monty Python and the Holy editor wars" PYTHON (MONTY) SOFTWARE LTD
22c937
22c937
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
22c937
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
22c937
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
22c937
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///