Karsten Hopp 4f72ab
To: vim-dev@vim.org
Karsten Hopp 4f72ab
Subject: Patch 7.1.227
Karsten Hopp 4f72ab
Fcc: outbox
Karsten Hopp 4f72ab
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 4f72ab
Mime-Version: 1.0
Karsten Hopp 4f72ab
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 4f72ab
Content-Transfer-Encoding: 8bit
Karsten Hopp 4f72ab
------------
Karsten Hopp 4f72ab
Karsten Hopp 4f72ab
Patch 7.1.227
Karsten Hopp 4f72ab
Problem:    Hang in syntax HL when moving over a ")". (Dominique Pelle)
Karsten Hopp 4f72ab
Solution:   Avoid storing a syntax state in the wrong position in the list of
Karsten Hopp 4f72ab
	    remembered states.
Karsten Hopp 4f72ab
Files:	    src/syntax.c
Karsten Hopp 4f72ab
Karsten Hopp 4f72ab
Karsten Hopp 4f72ab
*** ../vim-7.1.226/src/syntax.c	Sat Jan 12 16:45:25 2008
Karsten Hopp 4f72ab
--- src/syntax.c	Sat Jan 12 16:45:44 2008
Karsten Hopp 4f72ab
***************
Karsten Hopp 4f72ab
*** 372,378 ****
Karsten Hopp 4f72ab
  static int syn_stack_cleanup __ARGS((void));
Karsten Hopp 4f72ab
  static void syn_stack_free_entry __ARGS((buf_T *buf, synstate_T *p));
Karsten Hopp 4f72ab
  static synstate_T *syn_stack_find_entry __ARGS((linenr_T lnum));
Karsten Hopp 4f72ab
! static synstate_T *store_current_state __ARGS((synstate_T *sp));
Karsten Hopp 4f72ab
  static void load_current_state __ARGS((synstate_T *from));
Karsten Hopp 4f72ab
  static void invalidate_current_state __ARGS((void));
Karsten Hopp 4f72ab
  static int syn_stack_equal __ARGS((synstate_T *sp));
Karsten Hopp 4f72ab
--- 372,378 ----
Karsten Hopp 4f72ab
  static int syn_stack_cleanup __ARGS((void));
Karsten Hopp 4f72ab
  static void syn_stack_free_entry __ARGS((buf_T *buf, synstate_T *p));
Karsten Hopp 4f72ab
  static synstate_T *syn_stack_find_entry __ARGS((linenr_T lnum));
Karsten Hopp 4f72ab
! static synstate_T *store_current_state __ARGS((void));
Karsten Hopp 4f72ab
  static void load_current_state __ARGS((synstate_T *from));
Karsten Hopp 4f72ab
  static void invalidate_current_state __ARGS((void));
Karsten Hopp 4f72ab
  static int syn_stack_equal __ARGS((synstate_T *sp));
Karsten Hopp 4f72ab
***************
Karsten Hopp 4f72ab
*** 464,470 ****
Karsten Hopp 4f72ab
      synstate_T	*p;
Karsten Hopp 4f72ab
      synstate_T	*last_valid = NULL;
Karsten Hopp 4f72ab
      synstate_T	*last_min_valid = NULL;
Karsten Hopp 4f72ab
!     synstate_T	*sp, *prev;
Karsten Hopp 4f72ab
      linenr_T	parsed_lnum;
Karsten Hopp 4f72ab
      linenr_T	first_stored;
Karsten Hopp 4f72ab
      int		dist;
Karsten Hopp 4f72ab
--- 464,470 ----
Karsten Hopp 4f72ab
      synstate_T	*p;
Karsten Hopp 4f72ab
      synstate_T	*last_valid = NULL;
Karsten Hopp 4f72ab
      synstate_T	*last_min_valid = NULL;
Karsten Hopp 4f72ab
!     synstate_T	*sp, *prev = NULL;
Karsten Hopp 4f72ab
      linenr_T	parsed_lnum;
Karsten Hopp 4f72ab
      linenr_T	first_stored;
Karsten Hopp 4f72ab
      int		dist;
Karsten Hopp 4f72ab
***************
Karsten Hopp 4f72ab
*** 502,508 ****
Karsten Hopp 4f72ab
  	if (!current_state_stored)
Karsten Hopp 4f72ab
  	{
Karsten Hopp 4f72ab
  	    ++current_lnum;
Karsten Hopp 4f72ab
! 	    (void)store_current_state(NULL);
Karsten Hopp 4f72ab
  	}
Karsten Hopp 4f72ab
  
Karsten Hopp 4f72ab
  	/*
Karsten Hopp 4f72ab
--- 502,508 ----
Karsten Hopp 4f72ab
  	if (!current_state_stored)
Karsten Hopp 4f72ab
  	{
Karsten Hopp 4f72ab
  	    ++current_lnum;
Karsten Hopp 4f72ab
! 	    (void)store_current_state();
Karsten Hopp 4f72ab
  	}
Karsten Hopp 4f72ab
  
Karsten Hopp 4f72ab
  	/*
Karsten Hopp 4f72ab
***************
Karsten Hopp 4f72ab
*** 558,564 ****
Karsten Hopp 4f72ab
  	dist = 999999;
Karsten Hopp 4f72ab
      else
Karsten Hopp 4f72ab
  	dist = syn_buf->b_ml.ml_line_count / (syn_buf->b_sst_len - Rows) + 1;
Karsten Hopp 4f72ab
-     prev = syn_stack_find_entry(current_lnum);
Karsten Hopp 4f72ab
      while (current_lnum < lnum)
Karsten Hopp 4f72ab
      {
Karsten Hopp 4f72ab
  	syn_start_line();
Karsten Hopp 4f72ab
--- 558,563 ----
Karsten Hopp 4f72ab
***************
Karsten Hopp 4f72ab
*** 573,581 ****
Karsten Hopp 4f72ab
  	     * equal to the current state.  If so, then validate all saved
Karsten Hopp 4f72ab
  	     * states that depended on a change before the parsed line. */
Karsten Hopp 4f72ab
  	    if (prev == NULL)
Karsten Hopp 4f72ab
  		sp = syn_buf->b_sst_first;
Karsten Hopp 4f72ab
  	    else
Karsten Hopp 4f72ab
! 		sp = prev->sst_next;
Karsten Hopp 4f72ab
  	    if (sp != NULL
Karsten Hopp 4f72ab
  		    && sp->sst_lnum == current_lnum
Karsten Hopp 4f72ab
  		    && syn_stack_equal(sp))
Karsten Hopp 4f72ab
--- 572,584 ----
Karsten Hopp 4f72ab
  	     * equal to the current state.  If so, then validate all saved
Karsten Hopp 4f72ab
  	     * states that depended on a change before the parsed line. */
Karsten Hopp 4f72ab
  	    if (prev == NULL)
Karsten Hopp 4f72ab
+ 		prev = syn_stack_find_entry(current_lnum - 1);
Karsten Hopp 4f72ab
+ 	    if (prev == NULL)
Karsten Hopp 4f72ab
  		sp = syn_buf->b_sst_first;
Karsten Hopp 4f72ab
  	    else
Karsten Hopp 4f72ab
! 		sp = prev;
Karsten Hopp 4f72ab
! 	    while (sp != NULL && sp->sst_lnum < current_lnum)
Karsten Hopp 4f72ab
! 		sp = sp->sst_next;
Karsten Hopp 4f72ab
  	    if (sp != NULL
Karsten Hopp 4f72ab
  		    && sp->sst_lnum == current_lnum
Karsten Hopp 4f72ab
  		    && syn_stack_equal(sp))
Karsten Hopp 4f72ab
***************
Karsten Hopp 4f72ab
*** 601,607 ****
Karsten Hopp 4f72ab
  	    else if (prev == NULL
Karsten Hopp 4f72ab
  			|| current_lnum == lnum
Karsten Hopp 4f72ab
  			|| current_lnum >= prev->sst_lnum + dist)
Karsten Hopp 4f72ab
! 		prev = store_current_state(prev);
Karsten Hopp 4f72ab
  	}
Karsten Hopp 4f72ab
  
Karsten Hopp 4f72ab
  	/* This can take a long time: break when CTRL-C pressed.  The current
Karsten Hopp 4f72ab
--- 604,610 ----
Karsten Hopp 4f72ab
  	    else if (prev == NULL
Karsten Hopp 4f72ab
  			|| current_lnum == lnum
Karsten Hopp 4f72ab
  			|| current_lnum >= prev->sst_lnum + dist)
Karsten Hopp 4f72ab
! 		prev = store_current_state();
Karsten Hopp 4f72ab
  	}
Karsten Hopp 4f72ab
  
Karsten Hopp 4f72ab
  	/* This can take a long time: break when CTRL-C pressed.  The current
Karsten Hopp 4f72ab
***************
Karsten Hopp 4f72ab
*** 1353,1369 ****
Karsten Hopp 4f72ab
   * The current state must be valid for the start of the current_lnum line!
Karsten Hopp 4f72ab
   */
Karsten Hopp 4f72ab
      static synstate_T *
Karsten Hopp 4f72ab
! store_current_state(sp)
Karsten Hopp 4f72ab
!     synstate_T	*sp;	/* at or before where state is to be saved or
Karsten Hopp 4f72ab
! 				   NULL */
Karsten Hopp 4f72ab
  {
Karsten Hopp 4f72ab
      int		i;
Karsten Hopp 4f72ab
      synstate_T	*p;
Karsten Hopp 4f72ab
      bufstate_T	*bp;
Karsten Hopp 4f72ab
      stateitem_T	*cur_si;
Karsten Hopp 4f72ab
! 
Karsten Hopp 4f72ab
!     if (sp == NULL)
Karsten Hopp 4f72ab
! 	sp = syn_stack_find_entry(current_lnum);
Karsten Hopp 4f72ab
  
Karsten Hopp 4f72ab
      /*
Karsten Hopp 4f72ab
       * If the current state contains a start or end pattern that continues
Karsten Hopp 4f72ab
--- 1356,1368 ----
Karsten Hopp 4f72ab
   * The current state must be valid for the start of the current_lnum line!
Karsten Hopp 4f72ab
   */
Karsten Hopp 4f72ab
      static synstate_T *
Karsten Hopp 4f72ab
! store_current_state()
Karsten Hopp 4f72ab
  {
Karsten Hopp 4f72ab
      int		i;
Karsten Hopp 4f72ab
      synstate_T	*p;
Karsten Hopp 4f72ab
      bufstate_T	*bp;
Karsten Hopp 4f72ab
      stateitem_T	*cur_si;
Karsten Hopp 4f72ab
!     synstate_T	*sp = syn_stack_find_entry(current_lnum);
Karsten Hopp 4f72ab
  
Karsten Hopp 4f72ab
      /*
Karsten Hopp 4f72ab
       * If the current state contains a start or end pattern that continues
Karsten Hopp 4f72ab
***************
Karsten Hopp 4f72ab
*** 1667,1673 ****
Karsten Hopp 4f72ab
  	     * Store the current state in b_sst_array[] for later use.
Karsten Hopp 4f72ab
  	     */
Karsten Hopp 4f72ab
  	    ++current_lnum;
Karsten Hopp 4f72ab
! 	    (void)store_current_state(NULL);
Karsten Hopp 4f72ab
  	}
Karsten Hopp 4f72ab
      }
Karsten Hopp 4f72ab
  
Karsten Hopp 4f72ab
--- 1666,1672 ----
Karsten Hopp 4f72ab
  	     * Store the current state in b_sst_array[] for later use.
Karsten Hopp 4f72ab
  	     */
Karsten Hopp 4f72ab
  	    ++current_lnum;
Karsten Hopp 4f72ab
! 	    (void)store_current_state();
Karsten Hopp 4f72ab
  	}
Karsten Hopp 4f72ab
      }
Karsten Hopp 4f72ab
  
Karsten Hopp 4f72ab
*** ../vim-7.1.226/src/version.c	Sun Jan 13 17:11:25 2008
Karsten Hopp 4f72ab
--- src/version.c	Sun Jan 13 17:37:10 2008
Karsten Hopp 4f72ab
***************
Karsten Hopp 4f72ab
*** 668,669 ****
Karsten Hopp 4f72ab
--- 668,671 ----
Karsten Hopp 4f72ab
  {   /* Add new patch number below this line */
Karsten Hopp 4f72ab
+ /**/
Karsten Hopp 4f72ab
+     227,
Karsten Hopp 4f72ab
  /**/
Karsten Hopp 4f72ab
Karsten Hopp 4f72ab
-- 
Karsten Hopp 4f72ab
Dreams are free, but there's a small charge for alterations.
Karsten Hopp 4f72ab
Karsten Hopp 4f72ab
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 4f72ab
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 4f72ab
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 4f72ab
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///