lkundrak / rpms / vim

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