jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.293

073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.293
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.293
073263
Problem:    It is not possible to ignore composing characters at a specific
073263
	    point in a pattern.
073263
Solution:   Add the %C item.
073263
Files:	    src/regexp.c, src/regexp_nfa.c, src/testdir/test95.in,
073263
	    src/testdir/test95.ok, runtime/doc/pattern.txt
073263
073263
073263
*** ../vim-7.4.292/src/regexp.c	2014-05-13 18:03:55.729737466 +0200
073263
--- src/regexp.c	2014-05-13 18:27:08.725749659 +0200
073263
***************
073263
*** 244,249 ****
073263
--- 244,250 ----
073263
  
073263
  #define RE_MARK		207	/* mark cmp  Match mark position */
073263
  #define RE_VISUAL	208	/*	Match Visual area */
073263
+ #define RE_COMPOSING	209	/* any composing characters */
073263
  
073263
  /*
073263
   * Magic characters have a special meaning, they don't match literally.
073263
***************
073263
*** 2208,2213 ****
073263
--- 2209,2218 ----
073263
  		    ret = regnode(RE_VISUAL);
073263
  		    break;
073263
  
073263
+ 		case 'C':
073263
+ 		    ret = regnode(RE_COMPOSING);
073263
+ 		    break;
073263
+ 
073263
  		/* \%[abc]: Emit as a list of branches, all ending at the last
073263
  		 * branch which matches nothing. */
073263
  		case '[':
073263
***************
073263
*** 4710,4720 ****
073263
  			    status = RA_NOMATCH;
073263
  		    }
073263
  #ifdef FEAT_MBYTE
073263
! 		    /* Check for following composing character. */
073263
  		    if (status != RA_NOMATCH
073263
  			    && enc_utf8
073263
  			    && UTF_COMPOSINGLIKE(reginput, reginput + len)
073263
! 			    && !ireg_icombine)
073263
  		    {
073263
  			/* raaron: This code makes a composing character get
073263
  			 * ignored, which is the correct behavior (sometimes)
073263
--- 4715,4727 ----
073263
  			    status = RA_NOMATCH;
073263
  		    }
073263
  #ifdef FEAT_MBYTE
073263
! 		    /* Check for following composing character, unless %C
073263
! 		     * follows (skips over all composing chars). */
073263
  		    if (status != RA_NOMATCH
073263
  			    && enc_utf8
073263
  			    && UTF_COMPOSINGLIKE(reginput, reginput + len)
073263
! 			    && !ireg_icombine
073263
! 			    && OP(next) != RE_COMPOSING)
073263
  		    {
073263
  			/* raaron: This code makes a composing character get
073263
  			 * ignored, which is the correct behavior (sometimes)
073263
***************
073263
*** 4791,4796 ****
073263
--- 4798,4813 ----
073263
  		status = RA_NOMATCH;
073263
  	    break;
073263
  #endif
073263
+ 	  case RE_COMPOSING:
073263
+ #ifdef FEAT_MBYTE
073263
+ 	    if (enc_utf8)
073263
+ 	    {
073263
+ 		/* Skip composing characters. */
073263
+ 		while (utf_iscomposing(utf_ptr2char(reginput)))
073263
+ 		    mb_cptr_adv(reginput);
073263
+ 	    }
073263
+ #endif
073263
+ 	    break;
073263
  
073263
  	  case NOTHING:
073263
  	    break;
073263
*** ../vim-7.4.292/src/regexp_nfa.c	2014-05-13 16:44:25.633695709 +0200
073263
--- src/regexp_nfa.c	2014-05-13 19:25:58.285780556 +0200
073263
***************
073263
*** 81,86 ****
073263
--- 81,87 ----
073263
      NFA_COMPOSING,		    /* Next nodes in NFA are part of the
073263
  				       composing multibyte char */
073263
      NFA_END_COMPOSING,		    /* End of a composing char in the NFA */
073263
+     NFA_ANY_COMPOSING,		    /* \%C: Any composing characters. */
073263
      NFA_OPT_CHARS,		    /* \%[abc] */
073263
  
073263
      /* The following are used only in the postfix form, not in the NFA */
073263
***************
073263
*** 1418,1423 ****
073263
--- 1419,1428 ----
073263
  		    EMIT(NFA_VISUAL);
073263
  		    break;
073263
  
073263
+ 		case 'C':
073263
+ 		    EMIT(NFA_ANY_COMPOSING);
073263
+ 		    break;
073263
+ 
073263
  		case '[':
073263
  		    {
073263
  			int	    n;
073263
***************
073263
*** 2429,2434 ****
073263
--- 2434,2440 ----
073263
  	case NFA_MARK_LT:	STRCPY(code, "NFA_MARK_LT "); break;
073263
  	case NFA_CURSOR:	STRCPY(code, "NFA_CURSOR "); break;
073263
  	case NFA_VISUAL:	STRCPY(code, "NFA_VISUAL "); break;
073263
+ 	case NFA_ANY_COMPOSING:	STRCPY(code, "NFA_ANY_COMPOSING "); break;
073263
  
073263
  	case NFA_STAR:		STRCPY(code, "NFA_STAR "); break;
073263
  	case NFA_STAR_NONGREEDY: STRCPY(code, "NFA_STAR_NONGREEDY "); break;
073263
***************
073263
*** 2967,2972 ****
073263
--- 2973,2979 ----
073263
  	    case NFA_NLOWER_IC:
073263
  	    case NFA_UPPER_IC:
073263
  	    case NFA_NUPPER_IC:
073263
+ 	    case NFA_ANY_COMPOSING:
073263
  		/* possibly non-ascii */
073263
  #ifdef FEAT_MBYTE
073263
  		if (has_mbyte)
073263
***************
073263
*** 4152,4157 ****
073263
--- 4159,4165 ----
073263
  		continue;
073263
  
073263
  	    case NFA_ANY:
073263
+ 	    case NFA_ANY_COMPOSING:
073263
  	    case NFA_IDENT:
073263
  	    case NFA_SIDENT:
073263
  	    case NFA_KWORD:
073263
***************
073263
*** 4395,4401 ****
073263
      switch (state->c)
073263
      {
073263
  	case NFA_MATCH:
073263
! 	    nfa_match = TRUE;
073263
  	    break;
073263
  
073263
  	case NFA_SPLIT:
073263
--- 4403,4409 ----
073263
      switch (state->c)
073263
      {
073263
  	case NFA_MATCH:
073263
! //	    nfa_match = TRUE;
073263
  	    break;
073263
  
073263
  	case NFA_SPLIT:
073263
***************
073263
*** 5151,5156 ****
073263
--- 5159,5165 ----
073263
  
073263
  	case NFA_MATCH:
073263
  	case NFA_MCLOSE:
073263
+ 	case NFA_ANY_COMPOSING:
073263
  	    /* empty match works always */
073263
  	    return 0;
073263
  
073263
***************
073263
*** 5573,5578 ****
073263
--- 5582,5593 ----
073263
  	    {
073263
  	    case NFA_MATCH:
073263
  	      {
073263
+ #ifdef FEAT_MBYTE
073263
+ 		/* If the match ends before a composing characters and
073263
+ 		 * ireg_icombine is not set, that is not really a match. */
073263
+ 		if (enc_utf8 && !ireg_icombine && utf_iscomposing(curc))
073263
+ 		    break;
073263
+ #endif
073263
  		nfa_match = TRUE;
073263
  		copy_sub(&submatch->norm, &t->subs.norm);
073263
  #ifdef FEAT_SYN_HL
073263
***************
073263
*** 6120,6125 ****
073263
--- 6135,6157 ----
073263
  		}
073263
  		break;
073263
  
073263
+ 	    case NFA_ANY_COMPOSING:
073263
+ 		/* On a composing character skip over it.  Otherwise do
073263
+ 		 * nothing.  Always matches. */
073263
+ #ifdef FEAT_MBYTE
073263
+ 		if (enc_utf8 && utf_iscomposing(curc))
073263
+ 		{
073263
+ 		    add_off = clen;
073263
+ 		}
073263
+ 		else
073263
+ #endif
073263
+ 		{
073263
+ 		    add_here = TRUE;
073263
+ 		    add_off = 0;
073263
+ 		}
073263
+ 		add_state = t->state->out;
073263
+ 		break;
073263
+ 
073263
  	    /*
073263
  	     * Character classes like \a for alpha, \d for digit etc.
073263
  	     */
073263
***************
073263
*** 6484,6495 ****
073263
  		if (!result && ireg_ic)
073263
  		    result = MB_TOLOWER(c) == MB_TOLOWER(curc);
073263
  #ifdef FEAT_MBYTE
073263
! 		/* If there is a composing character which is not being
073263
! 		 * ignored there can be no match. Match with composing
073263
! 		 * character uses NFA_COMPOSING above. */
073263
! 		if (result && enc_utf8 && !ireg_icombine
073263
! 						&& clen != utf_char2len(curc))
073263
! 		    result = FALSE;
073263
  #endif
073263
  		ADD_STATE_IF_MATCH(t->state);
073263
  		break;
073263
--- 6516,6525 ----
073263
  		if (!result && ireg_ic)
073263
  		    result = MB_TOLOWER(c) == MB_TOLOWER(curc);
073263
  #ifdef FEAT_MBYTE
073263
! 		/* If ireg_icombine is not set only skip over the character
073263
! 		 * itself.  When it is set skip over composing characters. */
073263
! 		if (result && enc_utf8 && !ireg_icombine)
073263
! 		    clen = utf_char2len(curc);
073263
  #endif
073263
  		ADD_STATE_IF_MATCH(t->state);
073263
  		break;
073263
diff: ../vim-7.4.292/src/testdir/test95.insrc/testdir/test95.ok,: No such file or directory
073263
diff: src/testdir/test95.insrc/testdir/test95.ok,: No such file or directory
073263
*** ../vim-7.4.292/runtime/doc/pattern.txt	2013-08-10 13:24:59.000000000 +0200
073263
--- runtime/doc/pattern.txt	2014-05-13 18:59:57.621766895 +0200
073263
***************
073263
*** 545,550 ****
073263
--- 545,551 ----
073263
  |/\%u|	\%u	\%u	match specified multibyte character (eg \%u20ac)
073263
  |/\%U|	\%U	\%U	match specified large multibyte character (eg
073263
  			\%U12345678)
073263
+ |/\%C|	\%C	\%C	match any composing characters
073263
  
073263
  Example			matches ~
073263
  \<\I\i*		or
073263
***************
073263
*** 1207,1218 ****
073263
  8. Composing characters					*patterns-composing*
073263
  
073263
  							*/\Z*
073263
! When "\Z" appears anywhere in the pattern, composing characters are ignored.
073263
! Thus only the base characters need to match, the composing characters may be
073263
! different and the number of composing characters may differ.  Only relevant
073263
! when 'encoding' is "utf-8".
073263
  Exception: If the pattern starts with one or more composing characters, these
073263
  must match.
073263
  
073263
  When a composing character appears at the start of the pattern of after an
073263
  item that doesn't include the composing character, a match is found at any
073263
--- 1208,1225 ----
073263
  8. Composing characters					*patterns-composing*
073263
  
073263
  							*/\Z*
073263
! When "\Z" appears anywhere in the pattern, all composing characters are
073263
! ignored.  Thus only the base characters need to match, the composing
073263
! characters may be different and the number of composing characters may differ.
073263
! Only relevant when 'encoding' is "utf-8".
073263
  Exception: If the pattern starts with one or more composing characters, these
073263
  must match.
073263
+ 							*/\%C*
073263
+ Use "\%C" to skip any composing characters.  For example, the pattern "a" does
073263
+ not match in "càt" (where the a has the composing character 0x0300), but
073263
+ "a\%C" does.  Note that this does not match "cát" (where the á is character
073263
+ 0xe1, it does not have a compositing character).  It does match "cat" (where
073263
+ the a is just an a).
073263
  
073263
  When a composing character appears at the start of the pattern of after an
073263
  item that doesn't include the composing character, a match is found at any
073263
*** ../vim-7.4.292/src/version.c	2014-05-13 18:03:55.729737466 +0200
073263
--- src/version.c	2014-05-13 18:28:45.885750510 +0200
073263
***************
073263
*** 736,737 ****
073263
--- 736,739 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     293,
073263
  /**/
073263
073263
-- 
073263
hundred-and-one symptoms of being an internet addict:
073263
155. You forget to eat because you're too busy surfing the net.
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///