Karsten Hopp 901d3a
To: vim_dev@googlegroups.com
Karsten Hopp 901d3a
Subject: Patch 7.3.1092
Karsten Hopp 901d3a
Fcc: outbox
Karsten Hopp 901d3a
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 901d3a
Mime-Version: 1.0
Karsten Hopp 901d3a
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 901d3a
Content-Transfer-Encoding: 8bit
Karsten Hopp 901d3a
------------
Karsten Hopp 901d3a
Karsten Hopp 901d3a
Patch 7.3.1092
Karsten Hopp 901d3a
Problem:    Can't build with regexp debugging.  NFA debug output shows wrong
Karsten Hopp 901d3a
	    pattern.
Karsten Hopp 901d3a
Solution:   Fix debugging code for recent changes.  Add the pattern to the
Karsten Hopp 901d3a
	    program.
Karsten Hopp 901d3a
Files:	    src/regexp_nfa.c, src/regexp.h
Karsten Hopp 901d3a
Karsten Hopp 901d3a
Karsten Hopp 901d3a
*** ../vim-7.3.1091/src/regexp_nfa.c	2013-06-02 15:01:51.000000000 +0200
Karsten Hopp 901d3a
--- src/regexp_nfa.c	2013-06-02 15:48:57.000000000 +0200
Karsten Hopp 901d3a
***************
Karsten Hopp 901d3a
*** 3133,3144 ****
Karsten Hopp 901d3a
  	    {
Karsten Hopp 901d3a
  		int col;
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
! 		if (thread->sub.in_use <= 0)
Karsten Hopp 901d3a
  		    col = -1;
Karsten Hopp 901d3a
  		else if (REG_MULTI)
Karsten Hopp 901d3a
! 		    col = thread->sub.list.multi[0].start.col;
Karsten Hopp 901d3a
  		else
Karsten Hopp 901d3a
! 		    col = (int)(thread->sub.list.line[0].start - regline);
Karsten Hopp 901d3a
  		nfa_set_code(state->c);
Karsten Hopp 901d3a
  		fprintf(log_fd, "> Adding state %d to list %d. char %d: %s (start col %d)\n",
Karsten Hopp 901d3a
  		        abs(state->id), l->id, state->c, code, col);
Karsten Hopp 901d3a
--- 3133,3144 ----
Karsten Hopp 901d3a
  	    {
Karsten Hopp 901d3a
  		int col;
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
! 		if (thread->subs.norm.in_use <= 0)
Karsten Hopp 901d3a
  		    col = -1;
Karsten Hopp 901d3a
  		else if (REG_MULTI)
Karsten Hopp 901d3a
! 		    col = thread->subs.norm.list.multi[0].start.col;
Karsten Hopp 901d3a
  		else
Karsten Hopp 901d3a
! 		    col = (int)(thread->subs.norm.list.line[0].start - regline);
Karsten Hopp 901d3a
  		nfa_set_code(state->c);
Karsten Hopp 901d3a
  		fprintf(log_fd, "> Adding state %d to list %d. char %d: %s (start col %d)\n",
Karsten Hopp 901d3a
  		        abs(state->id), l->id, state->c, code, col);
Karsten Hopp 901d3a
***************
Karsten Hopp 901d3a
*** 3152,3163 ****
Karsten Hopp 901d3a
      {
Karsten Hopp 901d3a
  	int col;
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
! 	if (sub->in_use <= 0)
Karsten Hopp 901d3a
  	    col = -1;
Karsten Hopp 901d3a
  	else if (REG_MULTI)
Karsten Hopp 901d3a
! 	    col = sub->list.multi[0].start.col;
Karsten Hopp 901d3a
  	else
Karsten Hopp 901d3a
! 	    col = (int)(sub->list.line[0].start - regline);
Karsten Hopp 901d3a
  	nfa_set_code(state->c);
Karsten Hopp 901d3a
  	fprintf(log_fd, "> Processing state %d for list %d. char %d: %s (start col %d)\n",
Karsten Hopp 901d3a
  		abs(state->id), l->id, state->c, code, col);
Karsten Hopp 901d3a
--- 3152,3163 ----
Karsten Hopp 901d3a
      {
Karsten Hopp 901d3a
  	int col;
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
! 	if (subs->norm.in_use <= 0)
Karsten Hopp 901d3a
  	    col = -1;
Karsten Hopp 901d3a
  	else if (REG_MULTI)
Karsten Hopp 901d3a
! 	    col = subs->norm.list.multi[0].start.col;
Karsten Hopp 901d3a
  	else
Karsten Hopp 901d3a
! 	    col = (int)(subs->norm.list.line[0].start - regline);
Karsten Hopp 901d3a
  	nfa_set_code(state->c);
Karsten Hopp 901d3a
  	fprintf(log_fd, "> Processing state %d for list %d. char %d: %s (start col %d)\n",
Karsten Hopp 901d3a
  		abs(state->id), l->id, state->c, code, col);
Karsten Hopp 901d3a
***************
Karsten Hopp 901d3a
*** 3836,3847 ****
Karsten Hopp 901d3a
  	    {
Karsten Hopp 901d3a
  		int col;
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
! 		if (t->sub.in_use <= 0)
Karsten Hopp 901d3a
  		    col = -1;
Karsten Hopp 901d3a
  		else if (REG_MULTI)
Karsten Hopp 901d3a
! 		    col = t->sub.list.multi[0].start.col;
Karsten Hopp 901d3a
  		else
Karsten Hopp 901d3a
! 		    col = (int)(t->sub.list.line[0].start - regline);
Karsten Hopp 901d3a
  		nfa_set_code(t->state->c);
Karsten Hopp 901d3a
  		fprintf(log_fd, "(%d) char %d %s (start col %d) ... \n",
Karsten Hopp 901d3a
  			abs(t->state->id), (int)t->state->c, code, col);
Karsten Hopp 901d3a
--- 3836,3847 ----
Karsten Hopp 901d3a
  	    {
Karsten Hopp 901d3a
  		int col;
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
! 		if (t->subs.norm.in_use <= 0)
Karsten Hopp 901d3a
  		    col = -1;
Karsten Hopp 901d3a
  		else if (REG_MULTI)
Karsten Hopp 901d3a
! 		    col = t->subs.norm.list.multi[0].start.col;
Karsten Hopp 901d3a
  		else
Karsten Hopp 901d3a
! 		    col = (int)(t->subs.norm.list.line[0].start - regline);
Karsten Hopp 901d3a
  		nfa_set_code(t->state->c);
Karsten Hopp 901d3a
  		fprintf(log_fd, "(%d) char %d %s (start col %d) ... \n",
Karsten Hopp 901d3a
  			abs(t->state->id), (int)t->state->c, code, col);
Karsten Hopp 901d3a
***************
Karsten Hopp 901d3a
*** 4818,4823 ****
Karsten Hopp 901d3a
--- 4818,4826 ----
Karsten Hopp 901d3a
      nfa_has_zend = prog->has_zend;
Karsten Hopp 901d3a
      nfa_has_backref = prog->has_backref;
Karsten Hopp 901d3a
      nfa_nsubexpr = prog->nsubexp;
Karsten Hopp 901d3a
+ #ifdef DEBUG
Karsten Hopp 901d3a
+     nfa_regengine.expr = prog->pattern;
Karsten Hopp 901d3a
+ #endif
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
      nstate = prog->nstate;
Karsten Hopp 901d3a
      for (i = 0; i < nstate; ++i)
Karsten Hopp 901d3a
***************
Karsten Hopp 901d3a
*** 4828,4833 ****
Karsten Hopp 901d3a
--- 4831,4840 ----
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
      retval = nfa_regtry(prog, col);
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
+ #ifdef DEBUG
Karsten Hopp 901d3a
+     nfa_regengine.expr = NULL;
Karsten Hopp 901d3a
+ #endif
Karsten Hopp 901d3a
+ 
Karsten Hopp 901d3a
  theend:
Karsten Hopp 901d3a
      return retval;
Karsten Hopp 901d3a
  }
Karsten Hopp 901d3a
***************
Karsten Hopp 901d3a
*** 4921,4926 ****
Karsten Hopp 901d3a
--- 4928,4937 ----
Karsten Hopp 901d3a
      /* Remember whether this pattern has any \z specials in it. */
Karsten Hopp 901d3a
      prog->reghasz = re_has_z;
Karsten Hopp 901d3a
  #endif
Karsten Hopp 901d3a
+ #ifdef DEBUG
Karsten Hopp 901d3a
+     prog->pattern = vim_strsave(expr); /* memory will leak */
Karsten Hopp 901d3a
+     nfa_regengine.expr = NULL;
Karsten Hopp 901d3a
+ #endif
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
  out:
Karsten Hopp 901d3a
      vim_free(post_start);
Karsten Hopp 901d3a
*** ../vim-7.3.1091/src/regexp.h	2013-06-01 23:02:48.000000000 +0200
Karsten Hopp 901d3a
--- src/regexp.h	2013-06-02 15:42:57.000000000 +0200
Karsten Hopp 901d3a
***************
Karsten Hopp 901d3a
*** 86,98 ****
Karsten Hopp 901d3a
      regengine_T		*engine;
Karsten Hopp 901d3a
      unsigned		regflags;
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
!     regprog_T		regprog;
Karsten Hopp 901d3a
!     nfa_state_T		*start;
Karsten Hopp 901d3a
      int			has_zend;	/* pattern contains \ze */
Karsten Hopp 901d3a
      int			has_backref;	/* pattern contains \1 .. \9 */
Karsten Hopp 901d3a
  #ifdef FEAT_SYN_HL
Karsten Hopp 901d3a
      int			reghasz;
Karsten Hopp 901d3a
  #endif
Karsten Hopp 901d3a
      int			nsubexp;	/* number of () */
Karsten Hopp 901d3a
      int			nstate;
Karsten Hopp 901d3a
      nfa_state_T		state[0];	/* actually longer.. */
Karsten Hopp 901d3a
--- 86,100 ----
Karsten Hopp 901d3a
      regengine_T		*engine;
Karsten Hopp 901d3a
      unsigned		regflags;
Karsten Hopp 901d3a
  
Karsten Hopp 901d3a
!     nfa_state_T		*start;		/* points into state[] */
Karsten Hopp 901d3a
      int			has_zend;	/* pattern contains \ze */
Karsten Hopp 901d3a
      int			has_backref;	/* pattern contains \1 .. \9 */
Karsten Hopp 901d3a
  #ifdef FEAT_SYN_HL
Karsten Hopp 901d3a
      int			reghasz;
Karsten Hopp 901d3a
  #endif
Karsten Hopp 901d3a
+ #ifdef DEBUG
Karsten Hopp 901d3a
+     char_u		*pattern;
Karsten Hopp 901d3a
+ #endif
Karsten Hopp 901d3a
      int			nsubexp;	/* number of () */
Karsten Hopp 901d3a
      int			nstate;
Karsten Hopp 901d3a
      nfa_state_T		state[0];	/* actually longer.. */
Karsten Hopp 901d3a
*** ../vim-7.3.1091/src/version.c	2013-06-02 15:01:51.000000000 +0200
Karsten Hopp 901d3a
--- src/version.c	2013-06-02 15:53:16.000000000 +0200
Karsten Hopp 901d3a
***************
Karsten Hopp 901d3a
*** 730,731 ****
Karsten Hopp 901d3a
--- 730,733 ----
Karsten Hopp 901d3a
  {   /* Add new patch number below this line */
Karsten Hopp 901d3a
+ /**/
Karsten Hopp 901d3a
+     1092,
Karsten Hopp 901d3a
  /**/
Karsten Hopp 901d3a
Karsten Hopp 901d3a
-- 
Karsten Hopp 901d3a
I started out with nothing, and I still have most of it.
Karsten Hopp 901d3a
                                -- Michael Davis -- "Tonight Show"
Karsten Hopp 901d3a
Karsten Hopp 901d3a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 901d3a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 901d3a
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 901d3a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///