Karsten Hopp d6e760
To: vim_dev@googlegroups.com
Karsten Hopp d6e760
Subject: Patch 7.3.1012
Karsten Hopp d6e760
Fcc: outbox
Karsten Hopp d6e760
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp d6e760
Mime-Version: 1.0
Karsten Hopp d6e760
Content-Type: text/plain; charset=UTF-8
Karsten Hopp d6e760
Content-Transfer-Encoding: 8bit
Karsten Hopp d6e760
------------
Karsten Hopp d6e760
Karsten Hopp d6e760
Patch 7.3.1012
Karsten Hopp d6e760
Problem:    \Z does not work properly with the new regexp engine.
Karsten Hopp d6e760
Solution:   Make \Z work.  Add tests.
Karsten Hopp d6e760
Files:	    src/regexp_nfa.c, src/testdir/test95.in, src/testdir/test95.ok
Karsten Hopp d6e760
Karsten Hopp d6e760
Karsten Hopp d6e760
*** ../vim-7.3.1011/src/regexp_nfa.c	2013-05-24 21:59:50.000000000 +0200
Karsten Hopp d6e760
--- src/regexp_nfa.c	2013-05-24 22:46:00.000000000 +0200
Karsten Hopp d6e760
***************
Karsten Hopp d6e760
*** 1184,1197 ****
Karsten Hopp d6e760
  		    EMIT(NFA_CONCAT);
Karsten Hopp d6e760
  		}
Karsten Hopp d6e760
  		return OK;
Karsten Hopp d6e760
! 	    }		/* if exists closing ] */
Karsten Hopp d6e760
! 	    else if (reg_strict)
Karsten Hopp d6e760
  	    {
Karsten Hopp d6e760
  		syntax_error = TRUE;
Karsten Hopp d6e760
  		EMSG_RET_FAIL(_(e_missingbracket));
Karsten Hopp d6e760
  	    }
Karsten Hopp d6e760
  
Karsten Hopp d6e760
- 	/* FALLTHROUGH */
Karsten Hopp d6e760
  	default:
Karsten Hopp d6e760
  	    {
Karsten Hopp d6e760
  #ifdef FEAT_MBYTE
Karsten Hopp d6e760
--- 1184,1198 ----
Karsten Hopp d6e760
  		    EMIT(NFA_CONCAT);
Karsten Hopp d6e760
  		}
Karsten Hopp d6e760
  		return OK;
Karsten Hopp d6e760
! 	    } /* if exists closing ] */
Karsten Hopp d6e760
! 
Karsten Hopp d6e760
! 	    if (reg_strict)
Karsten Hopp d6e760
  	    {
Karsten Hopp d6e760
  		syntax_error = TRUE;
Karsten Hopp d6e760
  		EMSG_RET_FAIL(_(e_missingbracket));
Karsten Hopp d6e760
  	    }
Karsten Hopp d6e760
+ 	    /* FALLTHROUGH */
Karsten Hopp d6e760
  
Karsten Hopp d6e760
  	default:
Karsten Hopp d6e760
  	    {
Karsten Hopp d6e760
  #ifdef FEAT_MBYTE
Karsten Hopp d6e760
***************
Karsten Hopp d6e760
*** 1214,1220 ****
Karsten Hopp d6e760
  			EMIT(c);
Karsten Hopp d6e760
  			if (i > 0)
Karsten Hopp d6e760
  			    EMIT(NFA_CONCAT);
Karsten Hopp d6e760
! 			if (i += utf_char2len(c) >= plen)
Karsten Hopp d6e760
  			    break;
Karsten Hopp d6e760
  			c = utf_ptr2char(old_regparse + i);
Karsten Hopp d6e760
  		    }
Karsten Hopp d6e760
--- 1215,1221 ----
Karsten Hopp d6e760
  			EMIT(c);
Karsten Hopp d6e760
  			if (i > 0)
Karsten Hopp d6e760
  			    EMIT(NFA_CONCAT);
Karsten Hopp d6e760
! 			if ((i += utf_char2len(c)) >= plen)
Karsten Hopp d6e760
  			    break;
Karsten Hopp d6e760
  			c = utf_ptr2char(old_regparse + i);
Karsten Hopp d6e760
  		    }
Karsten Hopp d6e760
***************
Karsten Hopp d6e760
*** 2269,2275 ****
Karsten Hopp d6e760
  	    /* TODO */
Karsten Hopp d6e760
  	    if (regflags & RF_ICOMBINE)
Karsten Hopp d6e760
  	    {
Karsten Hopp d6e760
! 		goto normalchar;
Karsten Hopp d6e760
  	    }
Karsten Hopp d6e760
  #endif
Karsten Hopp d6e760
  	    /* FALLTHROUGH */
Karsten Hopp d6e760
--- 2270,2276 ----
Karsten Hopp d6e760
  	    /* TODO */
Karsten Hopp d6e760
  	    if (regflags & RF_ICOMBINE)
Karsten Hopp d6e760
  	    {
Karsten Hopp d6e760
! 		/* use the base character only */
Karsten Hopp d6e760
  	    }
Karsten Hopp d6e760
  #endif
Karsten Hopp d6e760
  	    /* FALLTHROUGH */
Karsten Hopp d6e760
***************
Karsten Hopp d6e760
*** 3145,3167 ****
Karsten Hopp d6e760
  		result = OK;
Karsten Hopp d6e760
  		sta = t->state->out;
Karsten Hopp d6e760
  		len = 0;
Karsten Hopp d6e760
! 		while (sta->c != NFA_END_COMPOSING && len < n)
Karsten Hopp d6e760
  		{
Karsten Hopp d6e760
! 		    if (len > 0)
Karsten Hopp d6e760
! 			mc = mb_ptr2char(reginput + len);
Karsten Hopp d6e760
! 		    if (mc != sta->c)
Karsten Hopp d6e760
! 			break;
Karsten Hopp d6e760
! 		    len += mb_char2len(mc);
Karsten Hopp d6e760
! 		    sta = sta->out;
Karsten Hopp d6e760
  		}
Karsten Hopp d6e760
  
Karsten Hopp d6e760
  		/* if input char length doesn't match regexp char length */
Karsten Hopp d6e760
  		if (len < n || sta->c != NFA_END_COMPOSING)
Karsten Hopp d6e760
  		    result = FAIL;
Karsten Hopp d6e760
  		end = t->state->out1;	    /* NFA_END_COMPOSING */
Karsten Hopp d6e760
- 		/* If \Z was present, then ignore composing characters */
Karsten Hopp d6e760
- 		if (ireg_icombine)
Karsten Hopp d6e760
- 		    result = 1 ^ sta->negated;
Karsten Hopp d6e760
  		ADD_POS_NEG_STATE(end);
Karsten Hopp d6e760
  		break;
Karsten Hopp d6e760
  	    }
Karsten Hopp d6e760
--- 3146,3176 ----
Karsten Hopp d6e760
  		result = OK;
Karsten Hopp d6e760
  		sta = t->state->out;
Karsten Hopp d6e760
  		len = 0;
Karsten Hopp d6e760
! 		if (ireg_icombine)
Karsten Hopp d6e760
  		{
Karsten Hopp d6e760
! 		    /* If \Z was present, then ignore composing characters. */
Karsten Hopp d6e760
! 		    /* TODO: How about negated? */
Karsten Hopp d6e760
! 		    if (sta->c != c)
Karsten Hopp d6e760
! 			result = FAIL;
Karsten Hopp d6e760
! 		    len = n;
Karsten Hopp d6e760
! 		    while (sta->c != NFA_END_COMPOSING)
Karsten Hopp d6e760
! 			sta = sta->out;
Karsten Hopp d6e760
  		}
Karsten Hopp d6e760
+ 		else
Karsten Hopp d6e760
+ 		    while (sta->c != NFA_END_COMPOSING && len < n)
Karsten Hopp d6e760
+ 		    {
Karsten Hopp d6e760
+ 			if (len > 0)
Karsten Hopp d6e760
+ 			    mc = mb_ptr2char(reginput + len);
Karsten Hopp d6e760
+ 			if (mc != sta->c)
Karsten Hopp d6e760
+ 			    break;
Karsten Hopp d6e760
+ 			len += mb_char2len(mc);
Karsten Hopp d6e760
+ 			sta = sta->out;
Karsten Hopp d6e760
+ 		    }
Karsten Hopp d6e760
  
Karsten Hopp d6e760
  		/* if input char length doesn't match regexp char length */
Karsten Hopp d6e760
  		if (len < n || sta->c != NFA_END_COMPOSING)
Karsten Hopp d6e760
  		    result = FAIL;
Karsten Hopp d6e760
  		end = t->state->out1;	    /* NFA_END_COMPOSING */
Karsten Hopp d6e760
  		ADD_POS_NEG_STATE(end);
Karsten Hopp d6e760
  		break;
Karsten Hopp d6e760
  	    }
Karsten Hopp d6e760
*** ../vim-7.3.1011/src/testdir/test95.in	2013-05-24 21:59:50.000000000 +0200
Karsten Hopp d6e760
--- src/testdir/test95.in	2013-05-24 23:02:13.000000000 +0200
Karsten Hopp d6e760
***************
Karsten Hopp d6e760
*** 41,46 ****
Karsten Hopp d6e760
--- 41,55 ----
Karsten Hopp d6e760
  
Karsten Hopp d6e760
  :"""" Test \Z
Karsten Hopp d6e760
  :call add(tl, ['ú\Z', 'x'])
Karsten Hopp d6e760
+ :call add(tl, ['יהוה\Z', 'יהוה', 'יהוה'])
Karsten Hopp d6e760
+ :call add(tl, ['יְהוָה\Z', 'יהוה', 'יהוה'])
Karsten Hopp d6e760
+ :call add(tl, ['יהוה\Z', 'יְהוָה', 'יְהוָה'])
Karsten Hopp d6e760
+ :call add(tl, ['יְהוָה\Z', 'יְהוָה', 'יְהוָה'])
Karsten Hopp d6e760
+ :call add(tl, ['יְ\Z', 'וְיַ', 'יַ'])
Karsten Hopp d6e760
+ :call add(tl, ["ק\u200d\u05b9x\\Z", "xק\u200d\u05b9xy", "ק\u200d\u05b9x"])
Karsten Hopp d6e760
+ :call add(tl, ["ק\u200d\u05b9x\\Z", "xק\u200dxy", "ק\u200dx"])
Karsten Hopp d6e760
+ :call add(tl, ["ק\u200dx\\Z", "xק\u200d\u05b9xy", "ק\u200d\u05b9x"])
Karsten Hopp d6e760
+ :call add(tl, ["ק\u200dx\\Z", "xק\u200dxy", "ק\u200dx"])
Karsten Hopp d6e760
  
Karsten Hopp d6e760
  :"""" Combining different tests and features
Karsten Hopp d6e760
  :call add(tl, ['[^[=a=]]\+', 'ddaãâbcd', 'dd'])
Karsten Hopp d6e760
*** ../vim-7.3.1011/src/testdir/test95.ok	2013-05-24 21:59:50.000000000 +0200
Karsten Hopp d6e760
--- src/testdir/test95.ok	2013-05-24 23:02:59.000000000 +0200
Karsten Hopp d6e760
***************
Karsten Hopp d6e760
*** 12,15 ****
Karsten Hopp d6e760
--- 12,24 ----
Karsten Hopp d6e760
  OK - .ม
Karsten Hopp d6e760
  OK - .ม่
Karsten Hopp d6e760
  OK - ú\Z
Karsten Hopp d6e760
+ OK - יהוה\Z
Karsten Hopp d6e760
+ OK - יְהוָה\Z
Karsten Hopp d6e760
+ OK - יהוה\Z
Karsten Hopp d6e760
+ OK - יְהוָה\Z
Karsten Hopp d6e760
+ OK - יְ\Z
Karsten Hopp d6e760
+ OK - ק‍ֹx\Z
Karsten Hopp d6e760
+ OK - ק‍ֹx\Z
Karsten Hopp d6e760
+ OK - ק‍x\Z
Karsten Hopp d6e760
+ OK - ק‍x\Z
Karsten Hopp d6e760
  OK - [^[=a=]]\+
Karsten Hopp d6e760
*** ../vim-7.3.1011/src/version.c	2013-05-24 21:59:50.000000000 +0200
Karsten Hopp d6e760
--- src/version.c	2013-05-24 23:08:21.000000000 +0200
Karsten Hopp d6e760
***************
Karsten Hopp d6e760
*** 730,731 ****
Karsten Hopp d6e760
--- 730,733 ----
Karsten Hopp d6e760
  {   /* Add new patch number below this line */
Karsten Hopp d6e760
+ /**/
Karsten Hopp d6e760
+     1012,
Karsten Hopp d6e760
  /**/
Karsten Hopp d6e760
Karsten Hopp d6e760
-- 
Karsten Hopp d6e760
BEDEVERE: And that, my lord, is how we know the Earth to be banana-shaped.
Karsten Hopp d6e760
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp d6e760
Karsten Hopp d6e760
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp d6e760
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp d6e760
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp d6e760
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///