Karsten Hopp af7e5c
To: vim_dev@googlegroups.com
Karsten Hopp af7e5c
Subject: Patch 7.3.1084
Karsten Hopp af7e5c
Fcc: outbox
Karsten Hopp af7e5c
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp af7e5c
Mime-Version: 1.0
Karsten Hopp af7e5c
Content-Type: text/plain; charset=UTF-8
Karsten Hopp af7e5c
Content-Transfer-Encoding: 8bit
Karsten Hopp af7e5c
------------
Karsten Hopp af7e5c
Karsten Hopp af7e5c
Patch 7.3.1084
Karsten Hopp af7e5c
Problem:    New regexp engine: only accepts up to \{,10}.
Karsten Hopp af7e5c
Solution:   Remove upper limit.  Remove dead code with NFA_PLUS.
Karsten Hopp af7e5c
Files:	    src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok
Karsten Hopp af7e5c
Karsten Hopp af7e5c
Karsten Hopp af7e5c
*** ../vim-7.3.1083/src/regexp_nfa.c	2013-05-31 22:14:48.000000000 +0200
Karsten Hopp af7e5c
--- src/regexp_nfa.c	2013-05-31 23:09:16.000000000 +0200
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 29,39 ****
Karsten Hopp af7e5c
  # define NFA_REGEXP_DEBUG_LOG	"nfa_regexp_debug.log"
Karsten Hopp af7e5c
  #endif
Karsten Hopp af7e5c
  
Karsten Hopp af7e5c
- /* Upper limit allowed for {m,n} repetitions handled by NFA */
Karsten Hopp af7e5c
- #define	    NFA_BRACES_MAXLIMIT		    10
Karsten Hopp af7e5c
- /* For allocating space for the postfix representation */
Karsten Hopp af7e5c
- #define	    NFA_POSTFIX_MULTIPLIER	    (NFA_BRACES_MAXLIMIT + 2)*2
Karsten Hopp af7e5c
- 
Karsten Hopp af7e5c
  enum
Karsten Hopp af7e5c
  {
Karsten Hopp af7e5c
      NFA_SPLIT = -1024,
Karsten Hopp af7e5c
--- 29,34 ----
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 44,50 ****
Karsten Hopp af7e5c
      NFA_CONCAT,
Karsten Hopp af7e5c
      NFA_OR,
Karsten Hopp af7e5c
      NFA_STAR,
Karsten Hopp af7e5c
-     NFA_PLUS,
Karsten Hopp af7e5c
      NFA_QUEST,
Karsten Hopp af7e5c
      NFA_QUEST_NONGREEDY,	    /* Non-greedy version of \? */
Karsten Hopp af7e5c
      NFA_NOT,			    /* used for [^ab] negated char ranges */
Karsten Hopp af7e5c
--- 39,44 ----
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 253,259 ****
Karsten Hopp af7e5c
      nstate = 0;
Karsten Hopp af7e5c
      istate = 0;
Karsten Hopp af7e5c
      /* A reasonable estimation for maximum size */
Karsten Hopp af7e5c
!     nstate_max = (int)(STRLEN(expr) + 1) * NFA_POSTFIX_MULTIPLIER;
Karsten Hopp af7e5c
  
Karsten Hopp af7e5c
      /* Some items blow up in size, such as [A-z].  Add more space for that.
Karsten Hopp af7e5c
       * When it is still not enough realloc_post_list() will be used. */
Karsten Hopp af7e5c
--- 247,253 ----
Karsten Hopp af7e5c
      nstate = 0;
Karsten Hopp af7e5c
      istate = 0;
Karsten Hopp af7e5c
      /* A reasonable estimation for maximum size */
Karsten Hopp af7e5c
!     nstate_max = (int)(STRLEN(expr) + 1) * 25;
Karsten Hopp af7e5c
  
Karsten Hopp af7e5c
      /* Some items blow up in size, such as [A-z].  Add more space for that.
Karsten Hopp af7e5c
       * When it is still not enough realloc_post_list() will be used. */
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 1365,1374 ****
Karsten Hopp af7e5c
  	     * string.
Karsten Hopp af7e5c
  	     * The submatch will the empty string.
Karsten Hopp af7e5c
  	     *
Karsten Hopp af7e5c
! 	     * In order to be consistent with the old engine, we disable
Karsten Hopp af7e5c
! 	     * NFA_PLUS, and replace <atom>+ with <atom><atom>*
Karsten Hopp af7e5c
  	     */
Karsten Hopp af7e5c
- 	    /*	EMIT(NFA_PLUS);	 */
Karsten Hopp af7e5c
  	    regnpar = old_regnpar;
Karsten Hopp af7e5c
  	    regparse = old_regparse;
Karsten Hopp af7e5c
  	    curchr = -1;
Karsten Hopp af7e5c
--- 1359,1367 ----
Karsten Hopp af7e5c
  	     * string.
Karsten Hopp af7e5c
  	     * The submatch will the empty string.
Karsten Hopp af7e5c
  	     *
Karsten Hopp af7e5c
! 	     * In order to be consistent with the old engine, we replace
Karsten Hopp af7e5c
! 	     * <atom>+ with <atom><atom>*
Karsten Hopp af7e5c
  	     */
Karsten Hopp af7e5c
  	    regnpar = old_regnpar;
Karsten Hopp af7e5c
  	    regparse = old_regparse;
Karsten Hopp af7e5c
  	    curchr = -1;
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 1443,1454 ****
Karsten Hopp af7e5c
  		break;
Karsten Hopp af7e5c
  	    }
Karsten Hopp af7e5c
  
Karsten Hopp af7e5c
! 	    if (maxval > NFA_BRACES_MAXLIMIT)
Karsten Hopp af7e5c
! 	    {
Karsten Hopp af7e5c
! 		/* This would yield a huge automaton and use too much memory.
Karsten Hopp af7e5c
! 		 * Revert to old engine */
Karsten Hopp af7e5c
  		return FAIL;
Karsten Hopp af7e5c
- 	    }
Karsten Hopp af7e5c
  
Karsten Hopp af7e5c
  	    /* Special case: x{0} or x{-0} */
Karsten Hopp af7e5c
  	    if (maxval == 0)
Karsten Hopp af7e5c
--- 1436,1444 ----
Karsten Hopp af7e5c
  		break;
Karsten Hopp af7e5c
  	    }
Karsten Hopp af7e5c
  
Karsten Hopp af7e5c
! 	    /* TODO: \{-} doesn't work yet */
Karsten Hopp af7e5c
! 	    if (maxval == MAX_LIMIT && !greedy)
Karsten Hopp af7e5c
  		return FAIL;
Karsten Hopp af7e5c
  
Karsten Hopp af7e5c
  	    /* Special case: x{0} or x{-0} */
Karsten Hopp af7e5c
  	    if (maxval == 0)
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 1478,1486 ****
Karsten Hopp af7e5c
  		    return FAIL;
Karsten Hopp af7e5c
  		/* after "minval" times, atoms are optional */
Karsten Hopp af7e5c
  		if (i + 1 > minval)
Karsten Hopp af7e5c
! 		    EMIT(quest);
Karsten Hopp af7e5c
  		if (old_post_pos != my_post_start)
Karsten Hopp af7e5c
  		    EMIT(NFA_CONCAT);
Karsten Hopp af7e5c
  	    }
Karsten Hopp af7e5c
  
Karsten Hopp af7e5c
  	    /* Go to just after the repeated atom and the \{} */
Karsten Hopp af7e5c
--- 1468,1483 ----
Karsten Hopp af7e5c
  		    return FAIL;
Karsten Hopp af7e5c
  		/* after "minval" times, atoms are optional */
Karsten Hopp af7e5c
  		if (i + 1 > minval)
Karsten Hopp af7e5c
! 		{
Karsten Hopp af7e5c
! 		    if (maxval == MAX_LIMIT)
Karsten Hopp af7e5c
! 			EMIT(NFA_STAR);
Karsten Hopp af7e5c
! 		    else
Karsten Hopp af7e5c
! 			EMIT(quest);
Karsten Hopp af7e5c
! 		}
Karsten Hopp af7e5c
  		if (old_post_pos != my_post_start)
Karsten Hopp af7e5c
  		    EMIT(NFA_CONCAT);
Karsten Hopp af7e5c
+ 		if (i + 1 > minval && maxval == MAX_LIMIT)
Karsten Hopp af7e5c
+ 		    break;
Karsten Hopp af7e5c
  	    }
Karsten Hopp af7e5c
  
Karsten Hopp af7e5c
  	    /* Go to just after the repeated atom and the \{} */
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 1779,1785 ****
Karsten Hopp af7e5c
  	case NFA_EOF:		STRCPY(code, "NFA_EOF "); break;
Karsten Hopp af7e5c
  	case NFA_BOF:		STRCPY(code, "NFA_BOF "); break;
Karsten Hopp af7e5c
  	case NFA_STAR:		STRCPY(code, "NFA_STAR "); break;
Karsten Hopp af7e5c
- 	case NFA_PLUS:		STRCPY(code, "NFA_PLUS "); break;
Karsten Hopp af7e5c
  	case NFA_NOT:		STRCPY(code, "NFA_NOT "); break;
Karsten Hopp af7e5c
  	case NFA_SKIP_CHAR:	STRCPY(code, "NFA_SKIP_CHAR"); break;
Karsten Hopp af7e5c
  	case NFA_OR:		STRCPY(code, "NFA_OR"); break;
Karsten Hopp af7e5c
--- 1776,1781 ----
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 2343,2363 ****
Karsten Hopp af7e5c
  	    PUSH(frag(s, append(e.out, list1(&s->out))));
Karsten Hopp af7e5c
  	    break;
Karsten Hopp af7e5c
  
Karsten Hopp af7e5c
- 	case NFA_PLUS:
Karsten Hopp af7e5c
- 	    /* One or more */
Karsten Hopp af7e5c
- 	    if (nfa_calc_size == TRUE)
Karsten Hopp af7e5c
- 	    {
Karsten Hopp af7e5c
- 		nstate++;
Karsten Hopp af7e5c
- 		break;
Karsten Hopp af7e5c
- 	    }
Karsten Hopp af7e5c
- 	    e = POP();
Karsten Hopp af7e5c
- 	    s = new_state(NFA_SPLIT, e.start, NULL);
Karsten Hopp af7e5c
- 	    if (s == NULL)
Karsten Hopp af7e5c
- 		goto theend;
Karsten Hopp af7e5c
- 	    patch(e.out, s);
Karsten Hopp af7e5c
- 	    PUSH(frag(e.start, list1(&s->out1)));
Karsten Hopp af7e5c
- 	    break;
Karsten Hopp af7e5c
- 
Karsten Hopp af7e5c
  	case NFA_SKIP_CHAR:
Karsten Hopp af7e5c
  	    /* Symbol of 0-length, Used in a repetition
Karsten Hopp af7e5c
  	     * with max/min count of 0 */
Karsten Hopp af7e5c
--- 2339,2344 ----
Karsten Hopp af7e5c
*** ../vim-7.3.1083/src/testdir/test64.in	2013-05-31 22:14:48.000000000 +0200
Karsten Hopp af7e5c
--- src/testdir/test64.in	2013-05-31 22:55:52.000000000 +0200
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 182,188 ****
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{0,}', 'oij sdigfusnf', ''])
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{0,}', 'aaaaa aa', 'aaaaa'])
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{2,}', 'sdfiougjdsafg'])
Karsten Hopp af7e5c
! :call add(tl, [0, 'a\{2,}', 'aaaaasfoij ', 'aaaaa'])
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{,0}', 'oidfguih iuhi hiu aaaa', ''])
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{,5}', 'abcd', 'a'])
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{,5}', 'aaaaaaaaaa', 'aaaaa'])
Karsten Hopp af7e5c
--- 182,190 ----
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{0,}', 'oij sdigfusnf', ''])
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{0,}', 'aaaaa aa', 'aaaaa'])
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{2,}', 'sdfiougjdsafg'])
Karsten Hopp af7e5c
! :call add(tl, [2, 'a\{2,}', 'aaaaasfoij ', 'aaaaa'])
Karsten Hopp af7e5c
! :call add(tl, [2, 'a\{5,}', 'xxaaaaxxx '])
Karsten Hopp af7e5c
! :call add(tl, [2, 'a\{5,}', 'xxaaaaaxxx ', 'aaaaa'])
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{,0}', 'oidfguih iuhi hiu aaaa', ''])
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{,5}', 'abcd', 'a'])
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{,5}', 'aaaaaaaaaa', 'aaaaa'])
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 225,231 ****
Karsten Hopp af7e5c
--- 227,235 ----
Karsten Hopp af7e5c
  :"
Karsten Hopp af7e5c
  :" Test greedy-ness and lazy-ness
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{-2,7}','aaaaaaaaaaaaa', 'aa'])
Karsten Hopp af7e5c
+ :call add(tl, [2, 'a\{-2,7}x','aaaaaaaaax', 'aaaaaaax'])
Karsten Hopp af7e5c
  :call add(tl, [2, 'a\{2,7}','aaaaaaaaaaaaaaaaaaaa', 'aaaaaaa'])
Karsten Hopp af7e5c
+ :call add(tl, [2, 'a\{2,7}x','aaaaaaaaax', 'aaaaaaax'])
Karsten Hopp af7e5c
  :call add(tl, [2, '\vx(.{-,8})yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz','ayxa','xayzxayz'])
Karsten Hopp af7e5c
  :call add(tl, [2, '\vx(.*)yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz', 'ayxayzxayzxa',''])
Karsten Hopp af7e5c
  :call add(tl, [2, '\v(a{1,2}){-2,3}','aaaaaaa','aaaa','aa'])
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 366,372 ****
Karsten Hopp af7e5c
  :call add(tl, [2, '\_[^a]\+', "asfi\n9888", "sfi\n9888"])
Karsten Hopp af7e5c
  :"
Karsten Hopp af7e5c
  :"""" Requiring lots of states.
Karsten Hopp af7e5c
! :call add(tl, [0, '[0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}', " 12345678-1234-1234-1234-123456789012 ", "12345678-1234-1234-1234-123456789012", "1234-"])
Karsten Hopp af7e5c
  :"
Karsten Hopp af7e5c
  :"
Karsten Hopp af7e5c
  :"""" Run the tests
Karsten Hopp af7e5c
--- 370,376 ----
Karsten Hopp af7e5c
  :call add(tl, [2, '\_[^a]\+', "asfi\n9888", "sfi\n9888"])
Karsten Hopp af7e5c
  :"
Karsten Hopp af7e5c
  :"""" Requiring lots of states.
Karsten Hopp af7e5c
! :call add(tl, [2, '[0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}', " 12345678-1234-1234-1234-123456789012 ", "12345678-1234-1234-1234-123456789012", "1234-"])
Karsten Hopp af7e5c
  :"
Karsten Hopp af7e5c
  :"
Karsten Hopp af7e5c
  :"""" Run the tests
Karsten Hopp af7e5c
*** ../vim-7.3.1083/src/testdir/test64.ok	2013-05-31 22:14:48.000000000 +0200
Karsten Hopp af7e5c
--- src/testdir/test64.ok	2013-05-31 23:02:02.000000000 +0200
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 389,394 ****
Karsten Hopp af7e5c
--- 389,401 ----
Karsten Hopp af7e5c
  OK 2 - a\{2,}
Karsten Hopp af7e5c
  OK 0 - a\{2,}
Karsten Hopp af7e5c
  OK 1 - a\{2,}
Karsten Hopp af7e5c
+ OK 2 - a\{2,}
Karsten Hopp af7e5c
+ OK 0 - a\{5,}
Karsten Hopp af7e5c
+ OK 1 - a\{5,}
Karsten Hopp af7e5c
+ OK 2 - a\{5,}
Karsten Hopp af7e5c
+ OK 0 - a\{5,}
Karsten Hopp af7e5c
+ OK 1 - a\{5,}
Karsten Hopp af7e5c
+ OK 2 - a\{5,}
Karsten Hopp af7e5c
  OK 0 - a\{,0}
Karsten Hopp af7e5c
  OK 1 - a\{,0}
Karsten Hopp af7e5c
  OK 2 - a\{,0}
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 486,494 ****
Karsten Hopp af7e5c
--- 493,507 ----
Karsten Hopp af7e5c
  OK 0 - a\{-2,7}
Karsten Hopp af7e5c
  OK 1 - a\{-2,7}
Karsten Hopp af7e5c
  OK 2 - a\{-2,7}
Karsten Hopp af7e5c
+ OK 0 - a\{-2,7}x
Karsten Hopp af7e5c
+ OK 1 - a\{-2,7}x
Karsten Hopp af7e5c
+ OK 2 - a\{-2,7}x
Karsten Hopp af7e5c
  OK 0 - a\{2,7}
Karsten Hopp af7e5c
  OK 1 - a\{2,7}
Karsten Hopp af7e5c
  OK 2 - a\{2,7}
Karsten Hopp af7e5c
+ OK 0 - a\{2,7}x
Karsten Hopp af7e5c
+ OK 1 - a\{2,7}x
Karsten Hopp af7e5c
+ OK 2 - a\{2,7}x
Karsten Hopp af7e5c
  OK 0 - \vx(.{-,8})yz(.*)
Karsten Hopp af7e5c
  OK 1 - \vx(.{-,8})yz(.*)
Karsten Hopp af7e5c
  OK 2 - \vx(.{-,8})yz(.*)
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 803,808 ****
Karsten Hopp af7e5c
--- 816,822 ----
Karsten Hopp af7e5c
  OK 2 - \_[^a]\+
Karsten Hopp af7e5c
  OK 0 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
Karsten Hopp af7e5c
  OK 1 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
Karsten Hopp af7e5c
+ OK 2 - [0-9a-zA-Z]\{8}-\([0-9a-zA-Z]\{4}-\)\{3}[0-9a-zA-Z]\{12}
Karsten Hopp af7e5c
  192.168.0.1
Karsten Hopp af7e5c
  192.168.0.1
Karsten Hopp af7e5c
  192.168.0.1
Karsten Hopp af7e5c
*** ../vim-7.3.1083/src/version.c	2013-05-31 22:14:48.000000000 +0200
Karsten Hopp af7e5c
--- src/version.c	2013-05-31 23:10:36.000000000 +0200
Karsten Hopp af7e5c
***************
Karsten Hopp af7e5c
*** 730,731 ****
Karsten Hopp af7e5c
--- 730,733 ----
Karsten Hopp af7e5c
  {   /* Add new patch number below this line */
Karsten Hopp af7e5c
+ /**/
Karsten Hopp af7e5c
+     1084,
Karsten Hopp af7e5c
  /**/
Karsten Hopp af7e5c
Karsten Hopp af7e5c
-- 
Karsten Hopp af7e5c
hundred-and-one symptoms of being an internet addict:
Karsten Hopp af7e5c
34. You laugh at people with a 10 Mbit connection.
Karsten Hopp af7e5c
Karsten Hopp af7e5c
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp af7e5c
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp af7e5c
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp af7e5c
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///