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