Karsten Hopp d0a039
To: vim_dev@googlegroups.com
Karsten Hopp d0a039
Subject: Patch 7.3.1113
Karsten Hopp d0a039
Fcc: outbox
Karsten Hopp d0a039
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp d0a039
Mime-Version: 1.0
Karsten Hopp d0a039
Content-Type: text/plain; charset=UTF-8
Karsten Hopp d0a039
Content-Transfer-Encoding: 8bit
Karsten Hopp d0a039
------------
Karsten Hopp d0a039
Karsten Hopp d0a039
Patch 7.3.1113
Karsten Hopp d0a039
Problem:    New regexp engine: \%'m not supported.
Karsten Hopp d0a039
Solution:   Implement \%'m.  Add tests.
Karsten Hopp d0a039
Files:      src/regexp.c, src/regexp_nfa.c, src/testdir/test64.in,
Karsten Hopp d0a039
            src/testdir/test64.ok
Karsten Hopp d0a039
Karsten Hopp d0a039
Karsten Hopp d0a039
*** ../vim-7.3.1112/src/regexp.c	2013-06-04 18:28:45.000000000 +0200
Karsten Hopp d0a039
--- src/regexp.c	2013-06-04 21:06:13.000000000 +0200
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 4401,4408 ****
Karsten Hopp d0a039
  	    break;
Karsten Hopp d0a039
  
Karsten Hopp d0a039
  	  case RE_MARK:
Karsten Hopp d0a039
! 	    /* Compare the mark position to the match position.  NOTE: Always
Karsten Hopp d0a039
! 	     * uses the current buffer. */
Karsten Hopp d0a039
  	    {
Karsten Hopp d0a039
  		int	mark = OPERAND(scan)[0];
Karsten Hopp d0a039
  		int	cmp = OPERAND(scan)[1];
Karsten Hopp d0a039
--- 4401,4407 ----
Karsten Hopp d0a039
  	    break;
Karsten Hopp d0a039
  
Karsten Hopp d0a039
  	  case RE_MARK:
Karsten Hopp d0a039
! 	    /* Compare the mark position to the match position. */
Karsten Hopp d0a039
  	    {
Karsten Hopp d0a039
  		int	mark = OPERAND(scan)[0];
Karsten Hopp d0a039
  		int	cmp = OPERAND(scan)[1];
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 4410,4416 ****
Karsten Hopp d0a039
  
Karsten Hopp d0a039
  		pos = getmark_buf(reg_buf, mark, FALSE);
Karsten Hopp d0a039
  		if (pos == NULL		     /* mark doesn't exist */
Karsten Hopp d0a039
! 			|| pos->lnum <= 0    /* mark isn't set (in curbuf) */
Karsten Hopp d0a039
  			|| (pos->lnum == reglnum + reg_firstlnum
Karsten Hopp d0a039
  				? (pos->col == (colnr_T)(reginput - regline)
Karsten Hopp d0a039
  				    ? (cmp == '<' || cmp == '>')
Karsten Hopp d0a039
--- 4409,4415 ----
Karsten Hopp d0a039
  
Karsten Hopp d0a039
  		pos = getmark_buf(reg_buf, mark, FALSE);
Karsten Hopp d0a039
  		if (pos == NULL		     /* mark doesn't exist */
Karsten Hopp d0a039
! 			|| pos->lnum <= 0    /* mark isn't set in reg_buf */
Karsten Hopp d0a039
  			|| (pos->lnum == reglnum + reg_firstlnum
Karsten Hopp d0a039
  				? (pos->col == (colnr_T)(reginput - regline)
Karsten Hopp d0a039
  				    ? (cmp == '<' || cmp == '>')
Karsten Hopp d0a039
*** ../vim-7.3.1112/src/regexp_nfa.c	2013-06-04 18:28:45.000000000 +0200
Karsten Hopp d0a039
--- src/regexp_nfa.c	2013-06-04 21:19:11.000000000 +0200
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 178,183 ****
Karsten Hopp d0a039
--- 178,186 ----
Karsten Hopp d0a039
      NFA_VCOL,		/*	Match cursor virtual column */
Karsten Hopp d0a039
      NFA_VCOL_GT,	/*	Match > cursor virtual column */
Karsten Hopp d0a039
      NFA_VCOL_LT,	/*	Match < cursor virtual column */
Karsten Hopp d0a039
+     NFA_MARK,		/*	Match mark */
Karsten Hopp d0a039
+     NFA_MARK_GT,	/*	Match > mark */
Karsten Hopp d0a039
+     NFA_MARK_LT,	/*	Match < mark */
Karsten Hopp d0a039
      NFA_VISUAL,		/*	Match Visual area */
Karsten Hopp d0a039
  
Karsten Hopp d0a039
      NFA_FIRST_NL = NFA_ANY + ADD_NL,
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 984,1002 ****
Karsten Hopp d0a039
  			{
Karsten Hopp d0a039
  			    EMIT(n);
Karsten Hopp d0a039
  			    if (c == 'l')
Karsten Hopp d0a039
  				EMIT(cmp == '<' ? NFA_LNUM_LT :
Karsten Hopp d0a039
! 					cmp == '>' ? NFA_LNUM_GT : NFA_LNUM);
Karsten Hopp d0a039
  			    else if (c == 'c')
Karsten Hopp d0a039
  				EMIT(cmp == '<' ? NFA_COL_LT :
Karsten Hopp d0a039
! 					cmp == '>' ? NFA_COL_GT : NFA_COL);
Karsten Hopp d0a039
  			    else
Karsten Hopp d0a039
  				EMIT(cmp == '<' ? NFA_VCOL_LT :
Karsten Hopp d0a039
! 					cmp == '>' ? NFA_VCOL_GT : NFA_VCOL);
Karsten Hopp d0a039
  			    break;
Karsten Hopp d0a039
  			}
Karsten Hopp d0a039
- 			else if (c == '\'')
Karsten Hopp d0a039
- 			    /* TODO: \%'m not supported yet */
Karsten Hopp d0a039
- 			    return FAIL;
Karsten Hopp d0a039
  		    }
Karsten Hopp d0a039
  		    syntax_error = TRUE;
Karsten Hopp d0a039
  		    EMSGN(_("E867: (NFA) Unknown operator '\\%%%c'"),
Karsten Hopp d0a039
--- 987,1013 ----
Karsten Hopp d0a039
  			{
Karsten Hopp d0a039
  			    EMIT(n);
Karsten Hopp d0a039
  			    if (c == 'l')
Karsten Hopp d0a039
+ 				/* \%{n}l  \%{n}<l  \%{n}>l  */
Karsten Hopp d0a039
  				EMIT(cmp == '<' ? NFA_LNUM_LT :
Karsten Hopp d0a039
! 				     cmp == '>' ? NFA_LNUM_GT : NFA_LNUM);
Karsten Hopp d0a039
  			    else if (c == 'c')
Karsten Hopp d0a039
+ 				/* \%{n}c  \%{n}<c  \%{n}>c  */
Karsten Hopp d0a039
  				EMIT(cmp == '<' ? NFA_COL_LT :
Karsten Hopp d0a039
! 				     cmp == '>' ? NFA_COL_GT : NFA_COL);
Karsten Hopp d0a039
  			    else
Karsten Hopp d0a039
+ 				/* \%{n}v  \%{n}<v  \%{n}>v  */
Karsten Hopp d0a039
  				EMIT(cmp == '<' ? NFA_VCOL_LT :
Karsten Hopp d0a039
! 				     cmp == '>' ? NFA_VCOL_GT : NFA_VCOL);
Karsten Hopp d0a039
! 			    break;
Karsten Hopp d0a039
! 			}
Karsten Hopp d0a039
! 			else if (c == '\'' && n == 0)
Karsten Hopp d0a039
! 			{
Karsten Hopp d0a039
! 			    /* \%'m  \%<'m  \%>'m  */
Karsten Hopp d0a039
! 			    EMIT(getchr());
Karsten Hopp d0a039
! 			    EMIT(cmp == '<' ? NFA_MARK_LT :
Karsten Hopp d0a039
! 				 cmp == '>' ? NFA_MARK_GT : NFA_MARK);
Karsten Hopp d0a039
  			    break;
Karsten Hopp d0a039
  			}
Karsten Hopp d0a039
  		    }
Karsten Hopp d0a039
  		    syntax_error = TRUE;
Karsten Hopp d0a039
  		    EMSGN(_("E867: (NFA) Unknown operator '\\%%%c'"),
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 1931,1936 ****
Karsten Hopp d0a039
--- 1942,1962 ----
Karsten Hopp d0a039
  	case NFA_BOW:		STRCPY(code, "NFA_BOW "); break;
Karsten Hopp d0a039
  	case NFA_EOF:		STRCPY(code, "NFA_EOF "); break;
Karsten Hopp d0a039
  	case NFA_BOF:		STRCPY(code, "NFA_BOF "); break;
Karsten Hopp d0a039
+ 	case NFA_LNUM:		STRCPY(code, "NFA_LNUM "); break;
Karsten Hopp d0a039
+ 	case NFA_LNUM_GT:	STRCPY(code, "NFA_LNUM_GT "); break;
Karsten Hopp d0a039
+ 	case NFA_LNUM_LT:	STRCPY(code, "NFA_LNUM_LT "); break;
Karsten Hopp d0a039
+ 	case NFA_COL:		STRCPY(code, "NFA_COL "); break;
Karsten Hopp d0a039
+ 	case NFA_COL_GT:	STRCPY(code, "NFA_COL_GT "); break;
Karsten Hopp d0a039
+ 	case NFA_COL_LT:	STRCPY(code, "NFA_COL_LT "); break;
Karsten Hopp d0a039
+ 	case NFA_VCOL:		STRCPY(code, "NFA_VCOL "); break;
Karsten Hopp d0a039
+ 	case NFA_VCOL_GT:	STRCPY(code, "NFA_VCOL_GT "); break;
Karsten Hopp d0a039
+ 	case NFA_VCOL_LT:	STRCPY(code, "NFA_VCOL_LT "); break;
Karsten Hopp d0a039
+ 	case NFA_MARK:		STRCPY(code, "NFA_MARK "); break;
Karsten Hopp d0a039
+ 	case NFA_MARK_GT:	STRCPY(code, "NFA_MARK_GT "); break;
Karsten Hopp d0a039
+ 	case NFA_MARK_LT:	STRCPY(code, "NFA_MARK_LT "); break;
Karsten Hopp d0a039
+ 	case NFA_CURSOR:	STRCPY(code, "NFA_CURSOR "); break;
Karsten Hopp d0a039
+ 	case NFA_VISUAL:	STRCPY(code, "NFA_VISUAL "); break;
Karsten Hopp d0a039
+ 
Karsten Hopp d0a039
  	case NFA_STAR:		STRCPY(code, "NFA_STAR "); break;
Karsten Hopp d0a039
  	case NFA_STAR_NONGREEDY: STRCPY(code, "NFA_STAR_NONGREEDY "); break;
Karsten Hopp d0a039
  	case NFA_QUEST:		STRCPY(code, "NFA_QUEST"); break;
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 2715,2720 ****
Karsten Hopp d0a039
--- 2741,2749 ----
Karsten Hopp d0a039
  	case NFA_COL:
Karsten Hopp d0a039
  	case NFA_COL_GT:
Karsten Hopp d0a039
  	case NFA_COL_LT:
Karsten Hopp d0a039
+ 	case NFA_MARK:
Karsten Hopp d0a039
+ 	case NFA_MARK_GT:
Karsten Hopp d0a039
+ 	case NFA_MARK_LT:
Karsten Hopp d0a039
  	    if (nfa_calc_size == TRUE)
Karsten Hopp d0a039
  	    {
Karsten Hopp d0a039
  		nstate += 1;
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 2724,2730 ****
Karsten Hopp d0a039
  	    s = alloc_state(*p, NULL, NULL);
Karsten Hopp d0a039
  	    if (s == NULL)
Karsten Hopp d0a039
  		goto theend;
Karsten Hopp d0a039
! 	    s->val = e1.start->c;
Karsten Hopp d0a039
  	    PUSH(frag(s, list1(&s->out)));
Karsten Hopp d0a039
  	    break;
Karsten Hopp d0a039
  
Karsten Hopp d0a039
--- 2753,2759 ----
Karsten Hopp d0a039
  	    s = alloc_state(*p, NULL, NULL);
Karsten Hopp d0a039
  	    if (s == NULL)
Karsten Hopp d0a039
  		goto theend;
Karsten Hopp d0a039
! 	    s->val = e1.start->c; /* lnum, col or mark name */
Karsten Hopp d0a039
  	    PUSH(frag(s, list1(&s->out)));
Karsten Hopp d0a039
  	    break;
Karsten Hopp d0a039
  
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 4723,4728 ****
Karsten Hopp d0a039
--- 4752,4781 ----
Karsten Hopp d0a039
  							    t->pim, &listidx);
Karsten Hopp d0a039
  		break;
Karsten Hopp d0a039
  
Karsten Hopp d0a039
+ 	    case NFA_MARK:
Karsten Hopp d0a039
+ 	    case NFA_MARK_GT:
Karsten Hopp d0a039
+ 	    case NFA_MARK_LT:
Karsten Hopp d0a039
+ 	      {
Karsten Hopp d0a039
+ 		pos_T	*pos = getmark_buf(reg_buf, t->state->val, FALSE);
Karsten Hopp d0a039
+ 
Karsten Hopp d0a039
+ 		/* Compare the mark position to the match position. */
Karsten Hopp d0a039
+ 		result = (pos != NULL		     /* mark doesn't exist */
Karsten Hopp d0a039
+ 			&& pos->lnum > 0    /* mark isn't set in reg_buf */
Karsten Hopp d0a039
+ 			&& (pos->lnum == reglnum + reg_firstlnum
Karsten Hopp d0a039
+ 				? (pos->col == (colnr_T)(reginput - regline)
Karsten Hopp d0a039
+ 				    ? t->state->c == NFA_MARK
Karsten Hopp d0a039
+ 				    : (pos->col < (colnr_T)(reginput - regline)
Karsten Hopp d0a039
+ 					? t->state->c == NFA_MARK_GT
Karsten Hopp d0a039
+ 					: t->state->c == NFA_MARK_LT))
Karsten Hopp d0a039
+ 				: (pos->lnum < reglnum + reg_firstlnum
Karsten Hopp d0a039
+ 				    ? t->state->c == NFA_MARK_GT
Karsten Hopp d0a039
+ 				    : t->state->c == NFA_MARK_LT)));
Karsten Hopp d0a039
+ 		if (result)
Karsten Hopp d0a039
+ 		    addstate_here(thislist, t->state->out, &t->subs,
Karsten Hopp d0a039
+ 							    t->pim, &listidx);
Karsten Hopp d0a039
+ 		break;
Karsten Hopp d0a039
+ 	      }
Karsten Hopp d0a039
+ 
Karsten Hopp d0a039
  	    case NFA_CURSOR:
Karsten Hopp d0a039
  		result = (reg_win != NULL
Karsten Hopp d0a039
  			&& (reglnum + reg_firstlnum == reg_win->w_cursor.lnum)
Karsten Hopp d0a039
*** ../vim-7.3.1112/src/testdir/test64.in	2013-06-04 18:28:45.000000000 +0200
Karsten Hopp d0a039
--- src/testdir/test64.in	2013-06-04 21:20:13.000000000 +0200
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 466,471 ****
Karsten Hopp d0a039
--- 466,478 ----
Karsten Hopp d0a039
  :/^Visual/+1,/^Visual/+4yank
Karsten Hopp d0a039
  Go?p:"
Karsten Hopp d0a039
  :"
Karsten Hopp d0a039
+ :" Check matching marks
Karsten Hopp d0a039
+ /^Marks:
Karsten Hopp d0a039
+ jfSmsfEme:.-4,.+6s/.\%>'s.*\%<'e../here/
Karsten Hopp d0a039
+ jfSmsj0fEme:.-4,.+6s/.\%>'s\_.*\%<'e../again/
Karsten Hopp d0a039
+ :/^Marks:/+1,/^Marks:/+3yank
Karsten Hopp d0a039
+ Go?p:"
Karsten Hopp d0a039
+ :"
Karsten Hopp d0a039
  :" Check patterns matching cursor position.
Karsten Hopp d0a039
  :func! Postest()
Karsten Hopp d0a039
   new
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 534,537 ****
Karsten Hopp d0a039
--- 541,549 ----
Karsten Hopp d0a039
  oooxofor foroxooo
Karsten Hopp d0a039
  oooxofor foroxooo
Karsten Hopp d0a039
  
Karsten Hopp d0a039
+ Marks:
Karsten Hopp d0a039
+ asdfSasdfsadfEasdf
Karsten Hopp d0a039
+ asdfSas
Karsten Hopp d0a039
+ dfsadfEasdf
Karsten Hopp d0a039
+ 
Karsten Hopp d0a039
  Results of test64:
Karsten Hopp d0a039
*** ../vim-7.3.1112/src/testdir/test64.ok	2013-06-04 18:28:45.000000000 +0200
Karsten Hopp d0a039
--- src/testdir/test64.ok	2013-06-04 20:55:08.000000000 +0200
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 862,867 ****
Karsten Hopp d0a039
--- 862,871 ----
Karsten Hopp d0a039
  AndAxAnd AndAxAnd
Karsten Hopp d0a039
  oooxOfOr fOrOxooo
Karsten Hopp d0a039
  oooxOfOr fOrOxooo
Karsten Hopp d0a039
+ 
Karsten Hopp d0a039
+ asdfhereasdf
Karsten Hopp d0a039
+ asdfagainasdf
Karsten Hopp d0a039
+ 
Karsten Hopp d0a039
  -0-
Karsten Hopp d0a039
  ffo
Karsten Hopp d0a039
  bob
Karsten Hopp d0a039
*** ../vim-7.3.1112/src/version.c	2013-06-04 18:28:45.000000000 +0200
Karsten Hopp d0a039
--- src/version.c	2013-06-04 21:25:20.000000000 +0200
Karsten Hopp d0a039
***************
Karsten Hopp d0a039
*** 730,731 ****
Karsten Hopp d0a039
--- 730,733 ----
Karsten Hopp d0a039
  {   /* Add new patch number below this line */
Karsten Hopp d0a039
+ /**/
Karsten Hopp d0a039
+     1113,
Karsten Hopp d0a039
  /**/
Karsten Hopp d0a039
Karsten Hopp d0a039
-- 
Karsten Hopp d0a039
hundred-and-one symptoms of being an internet addict:
Karsten Hopp d0a039
89. In addition to your e-mail address being on your business
Karsten Hopp d0a039
    cards you even have your own domain.
Karsten Hopp d0a039
Karsten Hopp d0a039
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp d0a039
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp d0a039
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp d0a039
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///