Blame SOURCES/7.4.262

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