Karsten Hopp 92e93c
To: vim-dev@vim.org
Karsten Hopp 92e93c
Subject: patch 7.1.050
Karsten Hopp 92e93c
Fcc: outbox
Karsten Hopp 92e93c
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 92e93c
Mime-Version: 1.0
Karsten Hopp 92e93c
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 92e93c
Content-Transfer-Encoding: 8bit
Karsten Hopp 92e93c
------------
Karsten Hopp 92e93c
Karsten Hopp 92e93c
Patch 7.1.050
Karsten Hopp 92e93c
Problem:    Possible crash when using C++ indenting. (Chris Monson)
Karsten Hopp 92e93c
Solution:   Keep the line pointer to the line to compare with.  Avoid going
Karsten Hopp 92e93c
	    past the end of line.
Karsten Hopp 92e93c
Files:	    src/misc1.c
Karsten Hopp 92e93c
Karsten Hopp 92e93c
Karsten Hopp 92e93c
*** ../vim-7.1.049/src/misc1.c	Tue Jul 24 15:25:27 2007
Karsten Hopp 92e93c
--- src/misc1.c	Fri Aug  3 21:07:17 2007
Karsten Hopp 92e93c
***************
Karsten Hopp 92e93c
*** 4820,4826 ****
Karsten Hopp 92e93c
  static int	cin_iswhileofdo __ARGS((char_u *, linenr_T, int));
Karsten Hopp 92e93c
  static int	cin_iswhileofdo_end __ARGS((int terminated, int	ind_maxparen, int ind_maxcomment));
Karsten Hopp 92e93c
  static int	cin_isbreak __ARGS((char_u *));
Karsten Hopp 92e93c
! static int	cin_is_cpp_baseclass __ARGS((char_u *line, colnr_T *col));
Karsten Hopp 92e93c
  static int	get_baseclass_amount __ARGS((int col, int ind_maxparen, int ind_maxcomment, int ind_cpp_baseclass));
Karsten Hopp 92e93c
  static int	cin_ends_in __ARGS((char_u *, char_u *, char_u *));
Karsten Hopp 92e93c
  static int	cin_skip2pos __ARGS((pos_T *trypos));
Karsten Hopp 92e93c
--- 4820,4826 ----
Karsten Hopp 92e93c
  static int	cin_iswhileofdo __ARGS((char_u *, linenr_T, int));
Karsten Hopp 92e93c
  static int	cin_iswhileofdo_end __ARGS((int terminated, int	ind_maxparen, int ind_maxcomment));
Karsten Hopp 92e93c
  static int	cin_isbreak __ARGS((char_u *));
Karsten Hopp 92e93c
! static int	cin_is_cpp_baseclass __ARGS((colnr_T *col));
Karsten Hopp 92e93c
  static int	get_baseclass_amount __ARGS((int col, int ind_maxparen, int ind_maxcomment, int ind_cpp_baseclass));
Karsten Hopp 92e93c
  static int	cin_ends_in __ARGS((char_u *, char_u *, char_u *));
Karsten Hopp 92e93c
  static int	cin_skip2pos __ARGS((pos_T *trypos));
Karsten Hopp 92e93c
***************
Karsten Hopp 92e93c
*** 5585,5597 ****
Karsten Hopp 92e93c
   * This is a lot of guessing.  Watch out for "cond ? func() : foo".
Karsten Hopp 92e93c
   */
Karsten Hopp 92e93c
      static int
Karsten Hopp 92e93c
! cin_is_cpp_baseclass(line, col)
Karsten Hopp 92e93c
!     char_u	*line;
Karsten Hopp 92e93c
      colnr_T	*col;	    /* return: column to align with */
Karsten Hopp 92e93c
  {
Karsten Hopp 92e93c
      char_u	*s;
Karsten Hopp 92e93c
      int		class_or_struct, lookfor_ctor_init, cpp_base_class;
Karsten Hopp 92e93c
      linenr_T	lnum = curwin->w_cursor.lnum;
Karsten Hopp 92e93c
  
Karsten Hopp 92e93c
      *col = 0;
Karsten Hopp 92e93c
  
Karsten Hopp 92e93c
--- 5585,5597 ----
Karsten Hopp 92e93c
   * This is a lot of guessing.  Watch out for "cond ? func() : foo".
Karsten Hopp 92e93c
   */
Karsten Hopp 92e93c
      static int
Karsten Hopp 92e93c
! cin_is_cpp_baseclass(col)
Karsten Hopp 92e93c
      colnr_T	*col;	    /* return: column to align with */
Karsten Hopp 92e93c
  {
Karsten Hopp 92e93c
      char_u	*s;
Karsten Hopp 92e93c
      int		class_or_struct, lookfor_ctor_init, cpp_base_class;
Karsten Hopp 92e93c
      linenr_T	lnum = curwin->w_cursor.lnum;
Karsten Hopp 92e93c
+     char_u	*line = ml_get_curline();
Karsten Hopp 92e93c
  
Karsten Hopp 92e93c
      *col = 0;
Karsten Hopp 92e93c
  
Karsten Hopp 92e93c
***************
Karsten Hopp 92e93c
*** 5619,5625 ****
Karsten Hopp 92e93c
       */
Karsten Hopp 92e93c
      while (lnum > 1)
Karsten Hopp 92e93c
      {
Karsten Hopp 92e93c
! 	s = skipwhite(ml_get(lnum - 1));
Karsten Hopp 92e93c
  	if (*s == '#' || *s == NUL)
Karsten Hopp 92e93c
  	    break;
Karsten Hopp 92e93c
  	while (*s != NUL)
Karsten Hopp 92e93c
--- 5619,5626 ----
Karsten Hopp 92e93c
       */
Karsten Hopp 92e93c
      while (lnum > 1)
Karsten Hopp 92e93c
      {
Karsten Hopp 92e93c
! 	line = ml_get(lnum - 1);
Karsten Hopp 92e93c
! 	s = skipwhite(line);
Karsten Hopp 92e93c
  	if (*s == '#' || *s == NUL)
Karsten Hopp 92e93c
  	    break;
Karsten Hopp 92e93c
  	while (*s != NUL)
Karsten Hopp 92e93c
***************
Karsten Hopp 92e93c
*** 5636,5642 ****
Karsten Hopp 92e93c
  	--lnum;
Karsten Hopp 92e93c
      }
Karsten Hopp 92e93c
  
Karsten Hopp 92e93c
!     s = cin_skipcomment(ml_get(lnum));
Karsten Hopp 92e93c
      for (;;)
Karsten Hopp 92e93c
      {
Karsten Hopp 92e93c
  	if (*s == NUL)
Karsten Hopp 92e93c
--- 5637,5644 ----
Karsten Hopp 92e93c
  	--lnum;
Karsten Hopp 92e93c
      }
Karsten Hopp 92e93c
  
Karsten Hopp 92e93c
!     line = ml_get(lnum);
Karsten Hopp 92e93c
!     s = cin_skipcomment(line);
Karsten Hopp 92e93c
      for (;;)
Karsten Hopp 92e93c
      {
Karsten Hopp 92e93c
  	if (*s == NUL)
Karsten Hopp 92e93c
***************
Karsten Hopp 92e93c
*** 5644,5650 ****
Karsten Hopp 92e93c
  	    if (lnum == curwin->w_cursor.lnum)
Karsten Hopp 92e93c
  		break;
Karsten Hopp 92e93c
  	    /* Continue in the cursor line. */
Karsten Hopp 92e93c
! 	    s = cin_skipcomment(ml_get(++lnum));
Karsten Hopp 92e93c
  	}
Karsten Hopp 92e93c
  
Karsten Hopp 92e93c
  	if (s[0] == ':')
Karsten Hopp 92e93c
--- 5646,5655 ----
Karsten Hopp 92e93c
  	    if (lnum == curwin->w_cursor.lnum)
Karsten Hopp 92e93c
  		break;
Karsten Hopp 92e93c
  	    /* Continue in the cursor line. */
Karsten Hopp 92e93c
! 	    line = ml_get(++lnum);
Karsten Hopp 92e93c
! 	    s = cin_skipcomment(line);
Karsten Hopp 92e93c
! 	    if (*s == NUL)
Karsten Hopp 92e93c
! 		continue;
Karsten Hopp 92e93c
  	}
Karsten Hopp 92e93c
  
Karsten Hopp 92e93c
  	if (s[0] == ':')
Karsten Hopp 92e93c
***************
Karsten Hopp 92e93c
*** 7113,7119 ****
Karsten Hopp 92e93c
  		n = FALSE;
Karsten Hopp 92e93c
  		if (lookfor != LOOKFOR_TERM && ind_cpp_baseclass > 0)
Karsten Hopp 92e93c
  		{
Karsten Hopp 92e93c
! 		    n = cin_is_cpp_baseclass(l, &col);
Karsten Hopp 92e93c
  		    l = ml_get_curline();
Karsten Hopp 92e93c
  		}
Karsten Hopp 92e93c
  		if (n)
Karsten Hopp 92e93c
--- 7118,7124 ----
Karsten Hopp 92e93c
  		n = FALSE;
Karsten Hopp 92e93c
  		if (lookfor != LOOKFOR_TERM && ind_cpp_baseclass > 0)
Karsten Hopp 92e93c
  		{
Karsten Hopp 92e93c
! 		    n = cin_is_cpp_baseclass(&col);
Karsten Hopp 92e93c
  		    l = ml_get_curline();
Karsten Hopp 92e93c
  		}
Karsten Hopp 92e93c
  		if (n)
Karsten Hopp 92e93c
***************
Karsten Hopp 92e93c
*** 7704,7710 ****
Karsten Hopp 92e93c
  		n = FALSE;
Karsten Hopp 92e93c
  		if (ind_cpp_baseclass != 0 && theline[0] != '{')
Karsten Hopp 92e93c
  		{
Karsten Hopp 92e93c
! 		    n = cin_is_cpp_baseclass(l, &col);
Karsten Hopp 92e93c
  		    l = ml_get_curline();
Karsten Hopp 92e93c
  		}
Karsten Hopp 92e93c
  		if (n)
Karsten Hopp 92e93c
--- 7709,7715 ----
Karsten Hopp 92e93c
  		n = FALSE;
Karsten Hopp 92e93c
  		if (ind_cpp_baseclass != 0 && theline[0] != '{')
Karsten Hopp 92e93c
  		{
Karsten Hopp 92e93c
! 		    n = cin_is_cpp_baseclass(&col);
Karsten Hopp 92e93c
  		    l = ml_get_curline();
Karsten Hopp 92e93c
  		}
Karsten Hopp 92e93c
  		if (n)
Karsten Hopp 92e93c
*** ../vim-7.1.049/src/version.c	Fri Aug  3 22:01:35 2007
Karsten Hopp 92e93c
--- src/version.c	Sat Aug  4 12:11:51 2007
Karsten Hopp 92e93c
***************
Karsten Hopp 92e93c
*** 668,669 ****
Karsten Hopp 92e93c
--- 668,671 ----
Karsten Hopp 92e93c
  {   /* Add new patch number below this line */
Karsten Hopp 92e93c
+ /**/
Karsten Hopp 92e93c
+     50,
Karsten Hopp 92e93c
  /**/
Karsten Hopp 92e93c
Karsten Hopp 92e93c
-- 
Karsten Hopp 92e93c
From "know your smileys":
Karsten Hopp 92e93c
 |-P	Reaction to unusually ugly C code
Karsten Hopp 92e93c
Karsten Hopp 92e93c
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 92e93c
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 92e93c
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 92e93c
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///