Karsten Hopp eb154b
To: vim_dev@googlegroups.com
Karsten Hopp eb154b
Subject: Patch 7.3.1128
Karsten Hopp eb154b
Fcc: outbox
Karsten Hopp eb154b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp eb154b
Mime-Version: 1.0
Karsten Hopp eb154b
Content-Type: text/plain; charset=UTF-8
Karsten Hopp eb154b
Content-Transfer-Encoding: 8bit
Karsten Hopp eb154b
------------
Karsten Hopp eb154b
Karsten Hopp eb154b
Patch 7.3.1128
Karsten Hopp eb154b
Problem:    Now that the NFA engine handles everything every failure is a
Karsten Hopp eb154b
	    syntax error.
Karsten Hopp eb154b
Solution:   Remove the syntax_error flag.
Karsten Hopp eb154b
Files:	    src/regexp.c, src/regexp_nfa.c
Karsten Hopp eb154b
Karsten Hopp eb154b
Karsten Hopp eb154b
*** ../vim-7.3.1127/src/regexp.c	2013-06-05 21:30:34.000000000 +0200
Karsten Hopp eb154b
--- src/regexp.c	2013-06-05 21:36:37.000000000 +0200
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 7924,7930 ****
Karsten Hopp eb154b
      regprog_T   *prog = NULL;
Karsten Hopp eb154b
      char_u	*expr = expr_arg;
Karsten Hopp eb154b
  
Karsten Hopp eb154b
-     syntax_error = FALSE;
Karsten Hopp eb154b
      regexp_engine = p_re;
Karsten Hopp eb154b
  
Karsten Hopp eb154b
      /* Check for prefix "\%#=", that sets the regexp engine */
Karsten Hopp eb154b
--- 7924,7929 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 7971,7989 ****
Karsten Hopp eb154b
  	    f = fopen(BT_REGEXP_DEBUG_LOG_NAME, "a");
Karsten Hopp eb154b
  	    if (f)
Karsten Hopp eb154b
  	    {
Karsten Hopp eb154b
! 		if (!syntax_error)
Karsten Hopp eb154b
! 		    fprintf(f, "NFA engine could not handle \"%s\"\n", expr);
Karsten Hopp eb154b
! 		else
Karsten Hopp eb154b
! 		    fprintf(f, "Syntax error in \"%s\"\n", expr);
Karsten Hopp eb154b
  		fclose(f);
Karsten Hopp eb154b
  	    }
Karsten Hopp eb154b
  	    else
Karsten Hopp eb154b
  		EMSG2("(NFA) Could not open \"%s\" to write !!!",
Karsten Hopp eb154b
                          BT_REGEXP_DEBUG_LOG_NAME);
Karsten Hopp eb154b
- 	    /*
Karsten Hopp eb154b
- 	    if (syntax_error)
Karsten Hopp eb154b
- 		EMSG("NFA Regexp: Syntax Error !");
Karsten Hopp eb154b
- 	    */
Karsten Hopp eb154b
  	}
Karsten Hopp eb154b
  #endif
Karsten Hopp eb154b
  	/*
Karsten Hopp eb154b
--- 7970,7981 ----
Karsten Hopp eb154b
  	    f = fopen(BT_REGEXP_DEBUG_LOG_NAME, "a");
Karsten Hopp eb154b
  	    if (f)
Karsten Hopp eb154b
  	    {
Karsten Hopp eb154b
! 		fprintf(f, "Syntax error in \"%s\"\n", expr);
Karsten Hopp eb154b
  		fclose(f);
Karsten Hopp eb154b
  	    }
Karsten Hopp eb154b
  	    else
Karsten Hopp eb154b
  		EMSG2("(NFA) Could not open \"%s\" to write !!!",
Karsten Hopp eb154b
                          BT_REGEXP_DEBUG_LOG_NAME);
Karsten Hopp eb154b
  	}
Karsten Hopp eb154b
  #endif
Karsten Hopp eb154b
  	/*
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 7992,8002 ****
Karsten Hopp eb154b
  	 * NFA engine.
Karsten Hopp eb154b
  	 */
Karsten Hopp eb154b
  	if (regexp_engine == AUTOMATIC_ENGINE)
Karsten Hopp eb154b
! 	    if (!syntax_error)
Karsten Hopp eb154b
! 		prog = bt_regengine.regcomp(expr, re_flags);
Karsten Hopp eb154b
! 
Karsten Hopp eb154b
!     }	    /* endif prog==NULL */
Karsten Hopp eb154b
! 
Karsten Hopp eb154b
  
Karsten Hopp eb154b
      return prog;
Karsten Hopp eb154b
  }
Karsten Hopp eb154b
--- 7984,7991 ----
Karsten Hopp eb154b
  	 * NFA engine.
Karsten Hopp eb154b
  	 */
Karsten Hopp eb154b
  	if (regexp_engine == AUTOMATIC_ENGINE)
Karsten Hopp eb154b
! 	    prog = bt_regengine.regcomp(expr, re_flags);
Karsten Hopp eb154b
!     }
Karsten Hopp eb154b
  
Karsten Hopp eb154b
      return prog;
Karsten Hopp eb154b
  }
Karsten Hopp eb154b
*** ../vim-7.3.1127/src/regexp_nfa.c	2013-06-05 21:30:34.000000000 +0200
Karsten Hopp eb154b
--- src/regexp_nfa.c	2013-06-05 21:35:29.000000000 +0200
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 221,243 ****
Karsten Hopp eb154b
  
Karsten Hopp eb154b
  static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c");
Karsten Hopp eb154b
  
Karsten Hopp eb154b
- /*
Karsten Hopp eb154b
-  * NFA errors can be of 3 types:
Karsten Hopp eb154b
-  * *** NFA runtime errors, when something unknown goes wrong. The NFA fails
Karsten Hopp eb154b
-  *     silently and revert the to backtracking engine.
Karsten Hopp eb154b
-  *     syntax_error = FALSE;
Karsten Hopp eb154b
-  * *** Regexp syntax errors, when the input regexp is not syntactically correct.
Karsten Hopp eb154b
-  *     The NFA engine displays an error message, and nothing else happens.
Karsten Hopp eb154b
-  *     syntax_error = TRUE
Karsten Hopp eb154b
-  * *** Unsupported features, when the input regexp uses an operator that is not
Karsten Hopp eb154b
-  *     implemented in the NFA. The NFA engine fails silently, and reverts to the
Karsten Hopp eb154b
-  *     old backtracking engine.
Karsten Hopp eb154b
-  *     syntax_error = FALSE
Karsten Hopp eb154b
-  * "The NFA fails" means that "compiling the regexp with the NFA fails":
Karsten Hopp eb154b
-  * nfa_regcomp() returns FAIL.
Karsten Hopp eb154b
-  */
Karsten Hopp eb154b
- static int syntax_error = FALSE;
Karsten Hopp eb154b
- 
Karsten Hopp eb154b
  /* NFA regexp \ze operator encountered. */
Karsten Hopp eb154b
  static int nfa_has_zend;
Karsten Hopp eb154b
  
Karsten Hopp eb154b
--- 221,226 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 692,698 ****
Karsten Hopp eb154b
      switch (c)
Karsten Hopp eb154b
      {
Karsten Hopp eb154b
  	case NUL:
Karsten Hopp eb154b
- 	    syntax_error = TRUE;
Karsten Hopp eb154b
  	    EMSG_RET_FAIL(_("E865: (NFA) Regexp end encountered prematurely"));
Karsten Hopp eb154b
  
Karsten Hopp eb154b
  	case Magic('^'):
Karsten Hopp eb154b
--- 675,680 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 814,820 ****
Karsten Hopp eb154b
  	case Magic('|'):
Karsten Hopp eb154b
  	case Magic('&'):
Karsten Hopp eb154b
  	case Magic(')'):
Karsten Hopp eb154b
- 	    syntax_error = TRUE;
Karsten Hopp eb154b
  	    EMSGN(_(e_misplaced), no_Magic(c));
Karsten Hopp eb154b
  	    return FAIL;
Karsten Hopp eb154b
  
Karsten Hopp eb154b
--- 796,801 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 825,831 ****
Karsten Hopp eb154b
  	case Magic('*'):
Karsten Hopp eb154b
  	case Magic('{'):
Karsten Hopp eb154b
  	    /* these should follow an atom, not form an atom */
Karsten Hopp eb154b
- 	    syntax_error = TRUE;
Karsten Hopp eb154b
  	    EMSGN(_(e_misplaced), no_Magic(c));
Karsten Hopp eb154b
  	    return FAIL;
Karsten Hopp eb154b
  
Karsten Hopp eb154b
--- 806,811 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 902,908 ****
Karsten Hopp eb154b
  		    break;
Karsten Hopp eb154b
  #endif
Karsten Hopp eb154b
  		default:
Karsten Hopp eb154b
- 		    syntax_error = TRUE;
Karsten Hopp eb154b
  		    EMSGN(_("E867: (NFA) Unknown operator '\\z%c'"),
Karsten Hopp eb154b
  								 no_Magic(c));
Karsten Hopp eb154b
  		    return FAIL;
Karsten Hopp eb154b
--- 882,887 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 1023,1029 ****
Karsten Hopp eb154b
  			    break;
Karsten Hopp eb154b
  			}
Karsten Hopp eb154b
  		    }
Karsten Hopp eb154b
- 		    syntax_error = TRUE;
Karsten Hopp eb154b
  		    EMSGN(_("E867: (NFA) Unknown operator '\\%%%c'"),
Karsten Hopp eb154b
  								 no_Magic(c));
Karsten Hopp eb154b
  		    return FAIL;
Karsten Hopp eb154b
--- 1002,1007 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 1359,1368 ****
Karsten Hopp eb154b
  	    } /* if exists closing ] */
Karsten Hopp eb154b
  
Karsten Hopp eb154b
  	    if (reg_strict)
Karsten Hopp eb154b
- 	    {
Karsten Hopp eb154b
- 		syntax_error = TRUE;
Karsten Hopp eb154b
  		EMSG_RET_FAIL(_(e_missingbracket));
Karsten Hopp eb154b
- 	    }
Karsten Hopp eb154b
  	    /* FALLTHROUGH */
Karsten Hopp eb154b
  
Karsten Hopp eb154b
  	default:
Karsten Hopp eb154b
--- 1337,1343 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 1512,1518 ****
Karsten Hopp eb154b
  	    }
Karsten Hopp eb154b
  	    if (i == 0)
Karsten Hopp eb154b
  	    {
Karsten Hopp eb154b
- 		syntax_error = TRUE;
Karsten Hopp eb154b
  		EMSGN(_("E869: (NFA) Unknown operator '\\@%c'"), op);
Karsten Hopp eb154b
  		return FAIL;
Karsten Hopp eb154b
  	    }
Karsten Hopp eb154b
--- 1487,1492 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 1543,1552 ****
Karsten Hopp eb154b
  		greedy = FALSE;
Karsten Hopp eb154b
  	    }
Karsten Hopp eb154b
  	    if (!read_limits(&minval, &maxval))
Karsten Hopp eb154b
- 	    {
Karsten Hopp eb154b
- 		syntax_error = TRUE;
Karsten Hopp eb154b
  		EMSG_RET_FAIL(_("E870: (NFA regexp) Error reading repetition limits"));
Karsten Hopp eb154b
! 	    }
Karsten Hopp eb154b
  	    /*  <atom>{0,inf}, <atom>{0,} and <atom>{}  are equivalent to
Karsten Hopp eb154b
  	     *  <atom>*  */
Karsten Hopp eb154b
  	    if (minval == 0 && maxval == MAX_LIMIT)
Karsten Hopp eb154b
--- 1517,1524 ----
Karsten Hopp eb154b
  		greedy = FALSE;
Karsten Hopp eb154b
  	    }
Karsten Hopp eb154b
  	    if (!read_limits(&minval, &maxval))
Karsten Hopp eb154b
  		EMSG_RET_FAIL(_("E870: (NFA regexp) Error reading repetition limits"));
Karsten Hopp eb154b
! 
Karsten Hopp eb154b
  	    /*  <atom>{0,inf}, <atom>{0,} and <atom>{}  are equivalent to
Karsten Hopp eb154b
  	     *  <atom>*  */
Karsten Hopp eb154b
  	    if (minval == 0 && maxval == MAX_LIMIT)
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 1614,1624 ****
Karsten Hopp eb154b
      }	/* end switch */
Karsten Hopp eb154b
  
Karsten Hopp eb154b
      if (re_multi_type(peekchr()) != NOT_MULTI)
Karsten Hopp eb154b
-     {
Karsten Hopp eb154b
  	/* Can't have a multi follow a multi. */
Karsten Hopp eb154b
- 	syntax_error = TRUE;
Karsten Hopp eb154b
  	EMSG_RET_FAIL(_("E871: (NFA regexp) Can't have a multi follow a multi !"));
Karsten Hopp eb154b
-     }
Karsten Hopp eb154b
  
Karsten Hopp eb154b
      return OK;
Karsten Hopp eb154b
  }
Karsten Hopp eb154b
--- 1586,1593 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 1767,1776 ****
Karsten Hopp eb154b
      if (paren == REG_PAREN)
Karsten Hopp eb154b
      {
Karsten Hopp eb154b
  	if (regnpar >= NSUBEXP) /* Too many `(' */
Karsten Hopp eb154b
- 	{
Karsten Hopp eb154b
- 	    syntax_error = TRUE;
Karsten Hopp eb154b
  	    EMSG_RET_FAIL(_("E872: (NFA regexp) Too many '('"));
Karsten Hopp eb154b
- 	}
Karsten Hopp eb154b
  	parno = regnpar++;
Karsten Hopp eb154b
      }
Karsten Hopp eb154b
  #ifdef FEAT_SYN_HL
Karsten Hopp eb154b
--- 1736,1742 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 1778,1787 ****
Karsten Hopp eb154b
      {
Karsten Hopp eb154b
  	/* Make a ZOPEN node. */
Karsten Hopp eb154b
  	if (regnzpar >= NSUBEXP)
Karsten Hopp eb154b
- 	{
Karsten Hopp eb154b
- 	    syntax_error = TRUE;
Karsten Hopp eb154b
  	    EMSG_RET_FAIL(_("E879: (NFA regexp) Too many \\z("));
Karsten Hopp eb154b
- 	}
Karsten Hopp eb154b
  	parno = regnzpar++;
Karsten Hopp eb154b
      }
Karsten Hopp eb154b
  #endif
Karsten Hopp eb154b
--- 1744,1750 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 1800,1806 ****
Karsten Hopp eb154b
      /* Check for proper termination. */
Karsten Hopp eb154b
      if (paren != REG_NOPAREN && getchr() != Magic(')'))
Karsten Hopp eb154b
      {
Karsten Hopp eb154b
- 	syntax_error = TRUE;
Karsten Hopp eb154b
  	if (paren == REG_NPAREN)
Karsten Hopp eb154b
  	    EMSG2_RET_FAIL(_(e_unmatchedpp), reg_magic == MAGIC_ALL);
Karsten Hopp eb154b
  	else
Karsten Hopp eb154b
--- 1763,1768 ----
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 1808,1814 ****
Karsten Hopp eb154b
      }
Karsten Hopp eb154b
      else if (paren == REG_NOPAREN && peekchr() != NUL)
Karsten Hopp eb154b
      {
Karsten Hopp eb154b
- 	syntax_error = TRUE;
Karsten Hopp eb154b
  	if (peekchr() == Magic(')'))
Karsten Hopp eb154b
  	    EMSG2_RET_FAIL(_(e_unmatchedpar), reg_magic == MAGIC_ALL);
Karsten Hopp eb154b
  	else
Karsten Hopp eb154b
--- 1770,1775 ----
Karsten Hopp eb154b
*** ../vim-7.3.1127/src/version.c	2013-06-05 21:30:34.000000000 +0200
Karsten Hopp eb154b
--- src/version.c	2013-06-05 21:42:28.000000000 +0200
Karsten Hopp eb154b
***************
Karsten Hopp eb154b
*** 730,731 ****
Karsten Hopp eb154b
--- 730,733 ----
Karsten Hopp eb154b
  {   /* Add new patch number below this line */
Karsten Hopp eb154b
+ /**/
Karsten Hopp eb154b
+     1128,
Karsten Hopp eb154b
  /**/
Karsten Hopp eb154b
Karsten Hopp eb154b
-- 
Karsten Hopp eb154b
From "know your smileys":
Karsten Hopp eb154b
 +<(:-) The Pope
Karsten Hopp eb154b
Karsten Hopp eb154b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp eb154b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp eb154b
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp eb154b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///