Karsten Hopp 1d8443
To: vim-dev@vim.org
Karsten Hopp 1d8443
Subject: patch 7.1.086
Karsten Hopp 1d8443
Fcc: outbox
Karsten Hopp 1d8443
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 1d8443
Mime-Version: 1.0
Karsten Hopp 1d8443
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 1d8443
Content-Transfer-Encoding: 8bit
Karsten Hopp 1d8443
------------
Karsten Hopp 1d8443
Karsten Hopp 1d8443
Patch 7.1.086
Karsten Hopp 1d8443
Problem:    Crash when using specific Python syntax highlighting.  (Quirk)
Karsten Hopp 1d8443
Solution:   Check for a negative index, coming from a keyword match at the
Karsten Hopp 1d8443
	    start of a line from a saved state.
Karsten Hopp 1d8443
Files:	    src/syntax.c
Karsten Hopp 1d8443
Karsten Hopp 1d8443
Karsten Hopp 1d8443
*** ../vim-7.1.085/src/syntax.c	Tue Aug 14 23:06:51 2007
Karsten Hopp 1d8443
--- src/syntax.c	Tue Aug 21 17:13:51 2007
Karsten Hopp 1d8443
***************
Karsten Hopp 1d8443
*** 279,285 ****
Karsten Hopp 1d8443
   */
Karsten Hopp 1d8443
  typedef struct state_item
Karsten Hopp 1d8443
  {
Karsten Hopp 1d8443
!     int		si_idx;			/* index of syntax pattern */
Karsten Hopp 1d8443
      int		si_id;			/* highlight group ID for keywords */
Karsten Hopp 1d8443
      int		si_trans_id;		/* idem, transparancy removed */
Karsten Hopp 1d8443
      int		si_m_lnum;		/* lnum of the match */
Karsten Hopp 1d8443
--- 279,286 ----
Karsten Hopp 1d8443
   */
Karsten Hopp 1d8443
  typedef struct state_item
Karsten Hopp 1d8443
  {
Karsten Hopp 1d8443
!     int		si_idx;			/* index of syntax pattern or
Karsten Hopp 1d8443
! 					   KEYWORD_IDX */
Karsten Hopp 1d8443
      int		si_id;			/* highlight group ID for keywords */
Karsten Hopp 1d8443
      int		si_trans_id;		/* idem, transparancy removed */
Karsten Hopp 1d8443
      int		si_m_lnum;		/* lnum of the match */
Karsten Hopp 1d8443
***************
Karsten Hopp 1d8443
*** 837,845 ****
Karsten Hopp 1d8443
  			    current_lnum = end_lnum;
Karsten Hopp 1d8443
  			    break;
Karsten Hopp 1d8443
  			}
Karsten Hopp 1d8443
! 			spp = &(SYN_ITEMS(syn_buf)[cur_si->si_idx]);
Karsten Hopp 1d8443
! 			found_flags = spp->sp_flags;
Karsten Hopp 1d8443
! 			found_match_idx = spp->sp_sync_idx;
Karsten Hopp 1d8443
  			found_current_lnum = current_lnum;
Karsten Hopp 1d8443
  			found_current_col = current_col;
Karsten Hopp 1d8443
  			found_m_endpos = cur_si->si_m_endpos;
Karsten Hopp 1d8443
--- 838,855 ----
Karsten Hopp 1d8443
  			    current_lnum = end_lnum;
Karsten Hopp 1d8443
  			    break;
Karsten Hopp 1d8443
  			}
Karsten Hopp 1d8443
! 			if (cur_si->si_idx < 0)
Karsten Hopp 1d8443
! 			{
Karsten Hopp 1d8443
! 			    /* Cannot happen? */
Karsten Hopp 1d8443
! 			    found_flags = 0;
Karsten Hopp 1d8443
! 			    found_match_idx = KEYWORD_IDX;
Karsten Hopp 1d8443
! 			}
Karsten Hopp 1d8443
! 			else
Karsten Hopp 1d8443
! 			{
Karsten Hopp 1d8443
! 			    spp = &(SYN_ITEMS(syn_buf)[cur_si->si_idx]);
Karsten Hopp 1d8443
! 			    found_flags = spp->sp_flags;
Karsten Hopp 1d8443
! 			    found_match_idx = spp->sp_sync_idx;
Karsten Hopp 1d8443
! 			}
Karsten Hopp 1d8443
  			found_current_lnum = current_lnum;
Karsten Hopp 1d8443
  			found_current_col = current_col;
Karsten Hopp 1d8443
  			found_m_endpos = cur_si->si_m_endpos;
Karsten Hopp 1d8443
***************
Karsten Hopp 1d8443
*** 2533,2538 ****
Karsten Hopp 1d8443
--- 2543,2552 ----
Karsten Hopp 1d8443
      stateitem_T	*sip = &CUR_STATE(idx);
Karsten Hopp 1d8443
      synpat_T	*spp;
Karsten Hopp 1d8443
  
Karsten Hopp 1d8443
+     /* This should not happen... */
Karsten Hopp 1d8443
+     if (sip->si_idx < 0)
Karsten Hopp 1d8443
+ 	return;
Karsten Hopp 1d8443
+ 
Karsten Hopp 1d8443
      spp = &(SYN_ITEMS(syn_buf)[sip->si_idx]);
Karsten Hopp 1d8443
      if (sip->si_flags & HL_MATCH)
Karsten Hopp 1d8443
  	sip->si_id = spp->sp_syn_match_id;
Karsten Hopp 1d8443
***************
Karsten Hopp 1d8443
*** 2648,2653 ****
Karsten Hopp 1d8443
--- 2662,2671 ----
Karsten Hopp 1d8443
      lpos_T	end_endpos;
Karsten Hopp 1d8443
      int		end_idx;
Karsten Hopp 1d8443
  
Karsten Hopp 1d8443
+     /* return quickly for a keyword */
Karsten Hopp 1d8443
+     if (sip->si_idx < 0)
Karsten Hopp 1d8443
+ 	return;
Karsten Hopp 1d8443
+ 
Karsten Hopp 1d8443
      /* Don't update when it's already done.  Can be a match of an end pattern
Karsten Hopp 1d8443
       * that started in a previous line.  Watch out: can also be a "keepend"
Karsten Hopp 1d8443
       * from a containing item. */
Karsten Hopp 1d8443
***************
Karsten Hopp 1d8443
*** 2759,2764 ****
Karsten Hopp 1d8443
--- 2777,2786 ----
Karsten Hopp 1d8443
      lpos_T	pos;
Karsten Hopp 1d8443
      char_u	*line;
Karsten Hopp 1d8443
      int		had_match = FALSE;
Karsten Hopp 1d8443
+ 
Karsten Hopp 1d8443
+     /* just in case we are invoked for a keyword */
Karsten Hopp 1d8443
+     if (idx < 0)
Karsten Hopp 1d8443
+ 	return;
Karsten Hopp 1d8443
  
Karsten Hopp 1d8443
      /*
Karsten Hopp 1d8443
       * Check for being called with a START pattern.
Karsten Hopp 1d8443
*** ../vim-7.1.085/src/version.c	Tue Aug 21 15:28:32 2007
Karsten Hopp 1d8443
--- src/version.c	Tue Aug 21 17:21:06 2007
Karsten Hopp 1d8443
***************
Karsten Hopp 1d8443
*** 668,669 ****
Karsten Hopp 1d8443
--- 668,671 ----
Karsten Hopp 1d8443
  {   /* Add new patch number below this line */
Karsten Hopp 1d8443
+ /**/
Karsten Hopp 1d8443
+     86,
Karsten Hopp 1d8443
  /**/
Karsten Hopp 1d8443
Karsten Hopp 1d8443
-- 
Karsten Hopp 1d8443
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 1d8443
222. You send more than 20 personal e-mails a day.
Karsten Hopp 1d8443
Karsten Hopp 1d8443
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 1d8443
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 1d8443
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 1d8443
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///