Blame SOURCES/7.4.262

d6ba96
To: vim_dev@googlegroups.com
d6ba96
Subject: Patch 7.4.262
d6ba96
Fcc: outbox
d6ba96
From: Bram Moolenaar <Bram@moolenaar.net>
d6ba96
Mime-Version: 1.0
d6ba96
Content-Type: text/plain; charset=UTF-8
d6ba96
Content-Transfer-Encoding: 8bit
d6ba96
------------
d6ba96
d6ba96
Patch 7.4.262
d6ba96
Problem:    Duplicate code in regexec().
d6ba96
Solution:   Add line_lbr flag to regexec_nl().
d6ba96
Files:	    src/regexp.c, src/regexp_nfa.c, src/regexp.h
d6ba96
d6ba96
d6ba96
*** ../vim-7.4.261/src/regexp.c	2014-04-23 18:48:43.546854558 +0200
d6ba96
--- src/regexp.c	2014-04-23 18:59:38.606838773 +0200
d6ba96
***************
d6ba96
*** 3709,3733 ****
d6ba96
  /* TRUE if using multi-line regexp. */
d6ba96
  #define REG_MULTI	(reg_match == NULL)
d6ba96
  
d6ba96
! static int  bt_regexec __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
d6ba96
  
d6ba96
  /*
d6ba96
   * Match a regexp against a string.
d6ba96
   * "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
d6ba96
   * Uses curbuf for line count and 'iskeyword'.
d6ba96
   *
d6ba96
   * Return TRUE if there is a match, FALSE if not.
d6ba96
   */
d6ba96
      static int
d6ba96
! bt_regexec(rmp, line, col)
d6ba96
      regmatch_T	*rmp;
d6ba96
      char_u	*line;	/* string to match against */
d6ba96
      colnr_T	col;	/* column to start looking for match */
d6ba96
  {
d6ba96
      reg_match = rmp;
d6ba96
      reg_mmatch = NULL;
d6ba96
      reg_maxline = 0;
d6ba96
!     reg_line_lbr = FALSE;
d6ba96
      reg_buf = curbuf;
d6ba96
      reg_win = NULL;
d6ba96
      ireg_ic = rmp->rm_ic;
d6ba96
--- 3709,3736 ----
d6ba96
  /* TRUE if using multi-line regexp. */
d6ba96
  #define REG_MULTI	(reg_match == NULL)
d6ba96
  
d6ba96
! static int  bt_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr));
d6ba96
! 
d6ba96
  
d6ba96
  /*
d6ba96
   * Match a regexp against a string.
d6ba96
   * "rmp->regprog" is a compiled regexp as returned by vim_regcomp().
d6ba96
   * Uses curbuf for line count and 'iskeyword'.
d6ba96
+  * if "line_lbr" is TRUE  consider a "\n" in "line" to be a line break.
d6ba96
   *
d6ba96
   * Return TRUE if there is a match, FALSE if not.
d6ba96
   */
d6ba96
      static int
d6ba96
! bt_regexec_nl(rmp, line, col, line_lbr)
d6ba96
      regmatch_T	*rmp;
d6ba96
      char_u	*line;	/* string to match against */
d6ba96
      colnr_T	col;	/* column to start looking for match */
d6ba96
+     int		line_lbr;
d6ba96
  {
d6ba96
      reg_match = rmp;
d6ba96
      reg_mmatch = NULL;
d6ba96
      reg_maxline = 0;
d6ba96
!     reg_line_lbr = line_lbr;
d6ba96
      reg_buf = curbuf;
d6ba96
      reg_win = NULL;
d6ba96
      ireg_ic = rmp->rm_ic;
d6ba96
***************
d6ba96
*** 3738,3772 ****
d6ba96
      return (bt_regexec_both(line, col, NULL) != 0);
d6ba96
  }
d6ba96
  
d6ba96
- #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
d6ba96
- 	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
d6ba96
- 
d6ba96
- static int  bt_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
d6ba96
- 
d6ba96
- /*
d6ba96
-  * Like vim_regexec(), but consider a "\n" in "line" to be a line break.
d6ba96
-  */
d6ba96
-     static int
d6ba96
- bt_regexec_nl(rmp, line, col)
d6ba96
-     regmatch_T	*rmp;
d6ba96
-     char_u	*line;	/* string to match against */
d6ba96
-     colnr_T	col;	/* column to start looking for match */
d6ba96
- {
d6ba96
-     reg_match = rmp;
d6ba96
-     reg_mmatch = NULL;
d6ba96
-     reg_maxline = 0;
d6ba96
-     reg_line_lbr = TRUE;
d6ba96
-     reg_buf = curbuf;
d6ba96
-     reg_win = NULL;
d6ba96
-     ireg_ic = rmp->rm_ic;
d6ba96
- #ifdef FEAT_MBYTE
d6ba96
-     ireg_icombine = FALSE;
d6ba96
- #endif
d6ba96
-     ireg_maxcol = 0;
d6ba96
-     return (bt_regexec_both(line, col, NULL) != 0);
d6ba96
- }
d6ba96
- #endif
d6ba96
- 
d6ba96
  static long bt_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
d6ba96
  
d6ba96
  /*
d6ba96
--- 3741,3746 ----
d6ba96
***************
d6ba96
*** 7985,7995 ****
d6ba96
  {
d6ba96
      bt_regcomp,
d6ba96
      bt_regfree,
d6ba96
-     bt_regexec,
d6ba96
- #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
d6ba96
- 	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
d6ba96
      bt_regexec_nl,
d6ba96
- #endif
d6ba96
      bt_regexec_multi
d6ba96
  #ifdef DEBUG
d6ba96
      ,(char_u *)""
d6ba96
--- 7959,7965 ----
d6ba96
***************
d6ba96
*** 8003,8013 ****
d6ba96
  {
d6ba96
      nfa_regcomp,
d6ba96
      nfa_regfree,
d6ba96
-     nfa_regexec,
d6ba96
- #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
d6ba96
- 	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
d6ba96
      nfa_regexec_nl,
d6ba96
- #endif
d6ba96
      nfa_regexec_multi
d6ba96
  #ifdef DEBUG
d6ba96
      ,(char_u *)""
d6ba96
--- 7973,7979 ----
d6ba96
***************
d6ba96
*** 8131,8137 ****
d6ba96
      char_u      *line;  /* string to match against */
d6ba96
      colnr_T     col;    /* column to start looking for match */
d6ba96
  {
d6ba96
!     return rmp->regprog->engine->regexec(rmp, line, col);
d6ba96
  }
d6ba96
  
d6ba96
  #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
d6ba96
--- 8097,8103 ----
d6ba96
      char_u      *line;  /* string to match against */
d6ba96
      colnr_T     col;    /* column to start looking for match */
d6ba96
  {
d6ba96
!     return rmp->regprog->engine->regexec_nl(rmp, line, col, FALSE);
d6ba96
  }
d6ba96
  
d6ba96
  #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
d6ba96
***************
d6ba96
*** 8145,8151 ****
d6ba96
      char_u *line;
d6ba96
      colnr_T col;
d6ba96
  {
d6ba96
!     return rmp->regprog->engine->regexec_nl(rmp, line, col);
d6ba96
  }
d6ba96
  #endif
d6ba96
  
d6ba96
--- 8111,8117 ----
d6ba96
      char_u *line;
d6ba96
      colnr_T col;
d6ba96
  {
d6ba96
!     return rmp->regprog->engine->regexec_nl(rmp, line, col, TRUE);
d6ba96
  }
d6ba96
  #endif
d6ba96
  
d6ba96
*** ../vim-7.4.261/src/regexp_nfa.c	2014-04-06 21:33:39.675363743 +0200
d6ba96
--- src/regexp_nfa.c	2014-04-23 19:00:44.354837189 +0200
d6ba96
***************
d6ba96
*** 311,317 ****
d6ba96
  static long nfa_regexec_both __ARGS((char_u *line, colnr_T col));
d6ba96
  static regprog_T *nfa_regcomp __ARGS((char_u *expr, int re_flags));
d6ba96
  static void nfa_regfree __ARGS((regprog_T *prog));
d6ba96
! static int nfa_regexec __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
d6ba96
  static long nfa_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
d6ba96
  static int match_follows __ARGS((nfa_state_T *startstate, int depth));
d6ba96
  static int failure_chance __ARGS((nfa_state_T *state, int depth));
d6ba96
--- 311,317 ----
d6ba96
  static long nfa_regexec_both __ARGS((char_u *line, colnr_T col));
d6ba96
  static regprog_T *nfa_regcomp __ARGS((char_u *expr, int re_flags));
d6ba96
  static void nfa_regfree __ARGS((regprog_T *prog));
d6ba96
! static int  nfa_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr));
d6ba96
  static long nfa_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
d6ba96
  static int match_follows __ARGS((nfa_state_T *startstate, int depth));
d6ba96
  static int failure_chance __ARGS((nfa_state_T *state, int depth));
d6ba96
***************
d6ba96
*** 7060,7078 ****
d6ba96
   * Match a regexp against a string.
d6ba96
   * "rmp->regprog" is a compiled regexp as returned by nfa_regcomp().
d6ba96
   * Uses curbuf for line count and 'iskeyword'.
d6ba96
   *
d6ba96
   * Return TRUE if there is a match, FALSE if not.
d6ba96
   */
d6ba96
      static int
d6ba96
! nfa_regexec(rmp, line, col)
d6ba96
      regmatch_T	*rmp;
d6ba96
      char_u	*line;	/* string to match against */
d6ba96
      colnr_T	col;	/* column to start looking for match */
d6ba96
  {
d6ba96
      reg_match = rmp;
d6ba96
      reg_mmatch = NULL;
d6ba96
      reg_maxline = 0;
d6ba96
!     reg_line_lbr = FALSE;
d6ba96
      reg_buf = curbuf;
d6ba96
      reg_win = NULL;
d6ba96
      ireg_ic = rmp->rm_ic;
d6ba96
--- 7060,7080 ----
d6ba96
   * Match a regexp against a string.
d6ba96
   * "rmp->regprog" is a compiled regexp as returned by nfa_regcomp().
d6ba96
   * Uses curbuf for line count and 'iskeyword'.
d6ba96
+  * If "line_lbr" is TRUE consider a "\n" in "line" to be a line break.
d6ba96
   *
d6ba96
   * Return TRUE if there is a match, FALSE if not.
d6ba96
   */
d6ba96
      static int
d6ba96
! nfa_regexec_nl(rmp, line, col, line_lbr)
d6ba96
      regmatch_T	*rmp;
d6ba96
      char_u	*line;	/* string to match against */
d6ba96
      colnr_T	col;	/* column to start looking for match */
d6ba96
+     int		line_lbr;
d6ba96
  {
d6ba96
      reg_match = rmp;
d6ba96
      reg_mmatch = NULL;
d6ba96
      reg_maxline = 0;
d6ba96
!     reg_line_lbr = line_lbr;
d6ba96
      reg_buf = curbuf;
d6ba96
      reg_win = NULL;
d6ba96
      ireg_ic = rmp->rm_ic;
d6ba96
***************
d6ba96
*** 7083,7117 ****
d6ba96
      return (nfa_regexec_both(line, col) != 0);
d6ba96
  }
d6ba96
  
d6ba96
- #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
d6ba96
- 	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
d6ba96
- 
d6ba96
- static int  nfa_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col));
d6ba96
- 
d6ba96
- /*
d6ba96
-  * Like nfa_regexec(), but consider a "\n" in "line" to be a line break.
d6ba96
-  */
d6ba96
-     static int
d6ba96
- nfa_regexec_nl(rmp, line, col)
d6ba96
-     regmatch_T	*rmp;
d6ba96
-     char_u	*line;	/* string to match against */
d6ba96
-     colnr_T	col;	/* column to start looking for match */
d6ba96
- {
d6ba96
-     reg_match = rmp;
d6ba96
-     reg_mmatch = NULL;
d6ba96
-     reg_maxline = 0;
d6ba96
-     reg_line_lbr = TRUE;
d6ba96
-     reg_buf = curbuf;
d6ba96
-     reg_win = NULL;
d6ba96
-     ireg_ic = rmp->rm_ic;
d6ba96
- #ifdef FEAT_MBYTE
d6ba96
-     ireg_icombine = FALSE;
d6ba96
- #endif
d6ba96
-     ireg_maxcol = 0;
d6ba96
-     return (nfa_regexec_both(line, col) != 0);
d6ba96
- }
d6ba96
- #endif
d6ba96
- 
d6ba96
  
d6ba96
  /*
d6ba96
   * Match a regexp against multiple lines.
d6ba96
--- 7085,7090 ----
d6ba96
*** ../vim-7.4.261/src/regexp.h	2013-06-11 10:53:14.000000000 +0200
d6ba96
--- src/regexp.h	2014-04-23 18:58:18.614840701 +0200
d6ba96
***************
d6ba96
*** 149,159 ****
d6ba96
  {
d6ba96
      regprog_T	*(*regcomp)(char_u*, int);
d6ba96
      void	(*regfree)(regprog_T *);
d6ba96
!     int		(*regexec)(regmatch_T*, char_u*, colnr_T);
d6ba96
! #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) \
d6ba96
! 	|| defined(FIND_REPLACE_DIALOG) || defined(PROTO)
d6ba96
!     int		(*regexec_nl)(regmatch_T*, char_u*, colnr_T);
d6ba96
! #endif
d6ba96
      long	(*regexec_multi)(regmmatch_T*, win_T*, buf_T*, linenr_T, colnr_T, proftime_T*);
d6ba96
  #ifdef DEBUG
d6ba96
      char_u	*expr;
d6ba96
--- 149,155 ----
d6ba96
  {
d6ba96
      regprog_T	*(*regcomp)(char_u*, int);
d6ba96
      void	(*regfree)(regprog_T *);
d6ba96
!     int		(*regexec_nl)(regmatch_T*, char_u*, colnr_T, int);
d6ba96
      long	(*regexec_multi)(regmmatch_T*, win_T*, buf_T*, linenr_T, colnr_T, proftime_T*);
d6ba96
  #ifdef DEBUG
d6ba96
      char_u	*expr;
d6ba96
*** ../vim-7.4.261/src/version.c	2014-04-23 18:48:43.546854558 +0200
d6ba96
--- src/version.c	2014-04-23 18:52:20.102849340 +0200
d6ba96
***************
d6ba96
*** 736,737 ****
d6ba96
--- 736,739 ----
d6ba96
  {   /* Add new patch number below this line */
d6ba96
+ /**/
d6ba96
+     262,
d6ba96
  /**/
d6ba96
d6ba96
-- 
d6ba96
From "know your smileys":
d6ba96
 ~#:-(	I just washed my hair, and I can't do nuthin' with it.
d6ba96
d6ba96
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
d6ba96
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
d6ba96
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
d6ba96
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///