Karsten Hopp 024a3d
To: vim_dev@googlegroups.com
Karsten Hopp 024a3d
Subject: Patch 7.3.1034
Karsten Hopp 024a3d
Fcc: outbox
Karsten Hopp 024a3d
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 024a3d
Mime-Version: 1.0
Karsten Hopp 024a3d
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 024a3d
Content-Transfer-Encoding: 8bit
Karsten Hopp 024a3d
------------
Karsten Hopp 024a3d
Karsten Hopp 024a3d
Patch 7.3.1034
Karsten Hopp 024a3d
Problem:    New regexp code using strange multi-byte code.
Karsten Hopp 024a3d
Solution:   Use the normal code to advance and backup pointers.
Karsten Hopp 024a3d
Files:	    src/regexp_nfa.c
Karsten Hopp 024a3d
Karsten Hopp 024a3d
Karsten Hopp 024a3d
*** ../vim-7.3.1033/src/regexp_nfa.c	2013-05-28 22:03:13.000000000 +0200
Karsten Hopp 024a3d
--- src/regexp_nfa.c	2013-05-28 22:25:28.000000000 +0200
Karsten Hopp 024a3d
***************
Karsten Hopp 024a3d
*** 188,195 ****
Karsten Hopp 024a3d
  static int nfa_regcomp_start __ARGS((char_u*expr, int re_flags));
Karsten Hopp 024a3d
  static int nfa_recognize_char_class __ARGS((char_u *start, char_u *end, int extra_newl));
Karsten Hopp 024a3d
  static int nfa_emit_equi_class __ARGS((int c, int neg));
Karsten Hopp 024a3d
- static void nfa_inc __ARGS((char_u **p));
Karsten Hopp 024a3d
- static void nfa_dec __ARGS((char_u **p));
Karsten Hopp 024a3d
  static int nfa_regatom __ARGS((void));
Karsten Hopp 024a3d
  static int nfa_regpiece __ARGS((void));
Karsten Hopp 024a3d
  static int nfa_regconcat __ARGS((void));
Karsten Hopp 024a3d
--- 188,193 ----
Karsten Hopp 024a3d
***************
Karsten Hopp 024a3d
*** 554,601 ****
Karsten Hopp 024a3d
   */
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
  /*
Karsten Hopp 024a3d
-  * Increments the pointer "p" by one (multi-byte) character.
Karsten Hopp 024a3d
-  */
Karsten Hopp 024a3d
-     static void
Karsten Hopp 024a3d
- nfa_inc(p)
Karsten Hopp 024a3d
-     char_u **p;
Karsten Hopp 024a3d
- {
Karsten Hopp 024a3d
- #ifdef FEAT_MBYTE
Karsten Hopp 024a3d
-     if (has_mbyte)
Karsten Hopp 024a3d
- 	mb_ptr2char_adv(p);
Karsten Hopp 024a3d
-     else
Karsten Hopp 024a3d
- #endif
Karsten Hopp 024a3d
- 	*p = *p + 1;
Karsten Hopp 024a3d
- }
Karsten Hopp 024a3d
- 
Karsten Hopp 024a3d
- /*
Karsten Hopp 024a3d
-  * Decrements the pointer "p" by one (multi-byte) character.
Karsten Hopp 024a3d
-  */
Karsten Hopp 024a3d
-     static void
Karsten Hopp 024a3d
- nfa_dec(p)
Karsten Hopp 024a3d
-     char_u **p;
Karsten Hopp 024a3d
- {
Karsten Hopp 024a3d
- #ifdef FEAT_MBYTE
Karsten Hopp 024a3d
-     char_u *p2, *oldp;
Karsten Hopp 024a3d
- 
Karsten Hopp 024a3d
-     if (has_mbyte)
Karsten Hopp 024a3d
-     {
Karsten Hopp 024a3d
- 	oldp = *p;
Karsten Hopp 024a3d
- 	/* Try to find the multibyte char that advances to the current
Karsten Hopp 024a3d
- 	 * position. */
Karsten Hopp 024a3d
- 	do
Karsten Hopp 024a3d
- 	{
Karsten Hopp 024a3d
- 	    *p = *p - 1;
Karsten Hopp 024a3d
- 	    p2 = *p;
Karsten Hopp 024a3d
- 	    mb_ptr2char_adv(&p2;;
Karsten Hopp 024a3d
- 	} while (p2 != oldp);
Karsten Hopp 024a3d
-     }
Karsten Hopp 024a3d
- #else
Karsten Hopp 024a3d
-     *p = *p - 1;
Karsten Hopp 024a3d
- #endif
Karsten Hopp 024a3d
- }
Karsten Hopp 024a3d
- 
Karsten Hopp 024a3d
- /*
Karsten Hopp 024a3d
   * Parse the lowest level.
Karsten Hopp 024a3d
   *
Karsten Hopp 024a3d
   * An atom can be one of a long list of items.  Many atoms match one character
Karsten Hopp 024a3d
--- 552,557 ----
Karsten Hopp 024a3d
***************
Karsten Hopp 024a3d
*** 963,969 ****
Karsten Hopp 024a3d
  			EMIT(NFA_OR);
Karsten Hopp 024a3d
  		    }
Karsten Hopp 024a3d
  		    regparse = endp;
Karsten Hopp 024a3d
! 		    nfa_inc(&regparse);
Karsten Hopp 024a3d
  		    return OK;
Karsten Hopp 024a3d
  		}
Karsten Hopp 024a3d
  		/*
Karsten Hopp 024a3d
--- 919,925 ----
Karsten Hopp 024a3d
  			EMIT(NFA_OR);
Karsten Hopp 024a3d
  		    }
Karsten Hopp 024a3d
  		    regparse = endp;
Karsten Hopp 024a3d
! 		    mb_ptr_adv(regparse);
Karsten Hopp 024a3d
  		    return OK;
Karsten Hopp 024a3d
  		}
Karsten Hopp 024a3d
  		/*
Karsten Hopp 024a3d
***************
Karsten Hopp 024a3d
*** 978,984 ****
Karsten Hopp 024a3d
  		{
Karsten Hopp 024a3d
  		    negated = TRUE;
Karsten Hopp 024a3d
  		    glue = NFA_CONCAT;
Karsten Hopp 024a3d
! 		    nfa_inc(&regparse);
Karsten Hopp 024a3d
  		}
Karsten Hopp 024a3d
  		if (*regparse == '-')
Karsten Hopp 024a3d
  		{
Karsten Hopp 024a3d
--- 934,940 ----
Karsten Hopp 024a3d
  		{
Karsten Hopp 024a3d
  		    negated = TRUE;
Karsten Hopp 024a3d
  		    glue = NFA_CONCAT;
Karsten Hopp 024a3d
! 		    mb_ptr_adv(regparse);
Karsten Hopp 024a3d
  		}
Karsten Hopp 024a3d
  		if (*regparse == '-')
Karsten Hopp 024a3d
  		{
Karsten Hopp 024a3d
***************
Karsten Hopp 024a3d
*** 986,992 ****
Karsten Hopp 024a3d
  		    EMIT(startc);
Karsten Hopp 024a3d
  		    TRY_NEG();
Karsten Hopp 024a3d
  		    EMIT_GLUE();
Karsten Hopp 024a3d
! 		    nfa_inc(&regparse);
Karsten Hopp 024a3d
  		}
Karsten Hopp 024a3d
  		/* Emit the OR branches for each character in the [] */
Karsten Hopp 024a3d
  		emit_range = FALSE;
Karsten Hopp 024a3d
--- 942,948 ----
Karsten Hopp 024a3d
  		    EMIT(startc);
Karsten Hopp 024a3d
  		    TRY_NEG();
Karsten Hopp 024a3d
  		    EMIT_GLUE();
Karsten Hopp 024a3d
! 		    mb_ptr_adv(regparse);
Karsten Hopp 024a3d
  		}
Karsten Hopp 024a3d
  		/* Emit the OR branches for each character in the [] */
Karsten Hopp 024a3d
  		emit_range = FALSE;
Karsten Hopp 024a3d
***************
Karsten Hopp 024a3d
*** 1090,1096 ****
Karsten Hopp 024a3d
  		    {
Karsten Hopp 024a3d
  			emit_range = TRUE;
Karsten Hopp 024a3d
  			startc = oldstartc;
Karsten Hopp 024a3d
! 			nfa_inc(&regparse);
Karsten Hopp 024a3d
  			continue;	    /* reading the end of the range */
Karsten Hopp 024a3d
  		    }
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
--- 1046,1052 ----
Karsten Hopp 024a3d
  		    {
Karsten Hopp 024a3d
  			emit_range = TRUE;
Karsten Hopp 024a3d
  			startc = oldstartc;
Karsten Hopp 024a3d
! 			mb_ptr_adv(regparse);
Karsten Hopp 024a3d
  			continue;	    /* reading the end of the range */
Karsten Hopp 024a3d
  		    }
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
***************
Karsten Hopp 024a3d
*** 1110,1116 ****
Karsten Hopp 024a3d
  			    )
Karsten Hopp 024a3d
  			)
Karsten Hopp 024a3d
  		    {
Karsten Hopp 024a3d
! 			nfa_inc(&regparse);
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
  			if (*regparse == 'n')
Karsten Hopp 024a3d
  			    startc = reg_string ? NL : NFA_NEWL;
Karsten Hopp 024a3d
--- 1066,1072 ----
Karsten Hopp 024a3d
  			    )
Karsten Hopp 024a3d
  			)
Karsten Hopp 024a3d
  		    {
Karsten Hopp 024a3d
! 			mb_ptr_adv(regparse);
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
  			if (*regparse == 'n')
Karsten Hopp 024a3d
  			    startc = reg_string ? NL : NFA_NEWL;
Karsten Hopp 024a3d
***************
Karsten Hopp 024a3d
*** 1125,1131 ****
Karsten Hopp 024a3d
  				/* TODO(RE) This needs more testing */
Karsten Hopp 024a3d
  				startc = coll_get_char();
Karsten Hopp 024a3d
  				got_coll_char = TRUE;
Karsten Hopp 024a3d
! 				nfa_dec(&regparse);
Karsten Hopp 024a3d
  			    }
Karsten Hopp 024a3d
  			    else
Karsten Hopp 024a3d
  			    {
Karsten Hopp 024a3d
--- 1081,1087 ----
Karsten Hopp 024a3d
  				/* TODO(RE) This needs more testing */
Karsten Hopp 024a3d
  				startc = coll_get_char();
Karsten Hopp 024a3d
  				got_coll_char = TRUE;
Karsten Hopp 024a3d
! 				mb_ptr_back(old_regparse, regparse);
Karsten Hopp 024a3d
  			    }
Karsten Hopp 024a3d
  			    else
Karsten Hopp 024a3d
  			    {
Karsten Hopp 024a3d
***************
Karsten Hopp 024a3d
*** 1210,1226 ****
Karsten Hopp 024a3d
  			EMIT_GLUE();
Karsten Hopp 024a3d
  		    }
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
! 		    nfa_inc(&regparse);
Karsten Hopp 024a3d
  		} /* while (p < endp) */
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
! 		nfa_dec(&regparse);
Karsten Hopp 024a3d
  		if (*regparse == '-')	    /* if last, '-' is just a char */
Karsten Hopp 024a3d
  		{
Karsten Hopp 024a3d
  		    EMIT('-');
Karsten Hopp 024a3d
  		    TRY_NEG();
Karsten Hopp 024a3d
  		    EMIT_GLUE();
Karsten Hopp 024a3d
  		}
Karsten Hopp 024a3d
! 		nfa_inc(&regparse);
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
  		if (extra == ADD_NL)	    /* \_[] also matches \n */
Karsten Hopp 024a3d
  		{
Karsten Hopp 024a3d
--- 1166,1182 ----
Karsten Hopp 024a3d
  			EMIT_GLUE();
Karsten Hopp 024a3d
  		    }
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
! 		    mb_ptr_adv(regparse);
Karsten Hopp 024a3d
  		} /* while (p < endp) */
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
! 		mb_ptr_back(old_regparse, regparse);
Karsten Hopp 024a3d
  		if (*regparse == '-')	    /* if last, '-' is just a char */
Karsten Hopp 024a3d
  		{
Karsten Hopp 024a3d
  		    EMIT('-');
Karsten Hopp 024a3d
  		    TRY_NEG();
Karsten Hopp 024a3d
  		    EMIT_GLUE();
Karsten Hopp 024a3d
  		}
Karsten Hopp 024a3d
! 		mb_ptr_adv(regparse);
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
  		if (extra == ADD_NL)	    /* \_[] also matches \n */
Karsten Hopp 024a3d
  		{
Karsten Hopp 024a3d
***************
Karsten Hopp 024a3d
*** 1231,1237 ****
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
  		/* skip the trailing ] */
Karsten Hopp 024a3d
  		regparse = endp;
Karsten Hopp 024a3d
! 		nfa_inc(&regparse);
Karsten Hopp 024a3d
  		if (negated == TRUE)
Karsten Hopp 024a3d
  		{
Karsten Hopp 024a3d
  		    /* Mark end of negated char range */
Karsten Hopp 024a3d
--- 1187,1193 ----
Karsten Hopp 024a3d
  
Karsten Hopp 024a3d
  		/* skip the trailing ] */
Karsten Hopp 024a3d
  		regparse = endp;
Karsten Hopp 024a3d
! 		mb_ptr_adv(regparse);
Karsten Hopp 024a3d
  		if (negated == TRUE)
Karsten Hopp 024a3d
  		{
Karsten Hopp 024a3d
  		    /* Mark end of negated char range */
Karsten Hopp 024a3d
*** ../vim-7.3.1033/src/version.c	2013-05-28 22:03:13.000000000 +0200
Karsten Hopp 024a3d
--- src/version.c	2013-05-28 22:29:18.000000000 +0200
Karsten Hopp 024a3d
***************
Karsten Hopp 024a3d
*** 730,731 ****
Karsten Hopp 024a3d
--- 730,733 ----
Karsten Hopp 024a3d
  {   /* Add new patch number below this line */
Karsten Hopp 024a3d
+ /**/
Karsten Hopp 024a3d
+     1034,
Karsten Hopp 024a3d
  /**/
Karsten Hopp 024a3d
Karsten Hopp 024a3d
-- 
Karsten Hopp 024a3d
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 024a3d
7. You finally do take that vacation, but only after buying a cellular modem
Karsten Hopp 024a3d
   and a laptop.
Karsten Hopp 024a3d
Karsten Hopp 024a3d
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 024a3d
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 024a3d
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 024a3d
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///