astepano / rpms / vim

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