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