To: vim-dev@vim.org Subject: Patch 6.3a.003 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.3a.003 Problem: E315 error with auto-formatting comments. (Henry Van Roessel) Solution: Pass the line number to same_leader(). Files: src/ops.c *** ../vim-6.3a.002/src/ops.c Fri May 7 10:59:38 2004 --- src/ops.c Sat May 8 12:27:21 2004 *************** *** 122,128 **** #endif static int ends_in_white __ARGS((linenr_T lnum)); #ifdef FEAT_COMMENTS ! static int same_leader __ARGS((int, char_u *, int, char_u *)); static int fmt_check_par __ARGS((linenr_T, int *, char_u **, int do_comments)); #else static int fmt_check_par __ARGS((linenr_T)); --- 122,128 ---- #endif static int ends_in_white __ARGS((linenr_T lnum)); #ifdef FEAT_COMMENTS ! static int same_leader __ARGS((linenr_T lnum, int, char_u *, int, char_u *)); static int fmt_check_par __ARGS((linenr_T, int *, char_u **, int do_comments)); #else static int fmt_check_par __ARGS((linenr_T)); *************** *** 4082,4093 **** #ifdef FEAT_COMMENTS /* ! * Return TRUE if the two comment leaders given are the same. The cursor is ! * in the first line. White-space is ignored. Note that the whole of * 'leader1' must match 'leader2_len' characters from 'leader2' -- webb */ static int ! same_leader(leader1_len, leader1_flags, leader2_len, leader2_flags) int leader1_len; char_u *leader1_flags; int leader2_len; --- 4082,4094 ---- #ifdef FEAT_COMMENTS /* ! * Return TRUE if the two comment leaders given are the same. "lnum" is ! * the first line. White-space is ignored. Note that the whole of * 'leader1' must match 'leader2_len' characters from 'leader2' -- webb */ static int ! same_leader(lnum, leader1_len, leader1_flags, leader2_len, leader2_flags) ! linenr_T lnum; int leader1_len; char_u *leader1_flags; int leader2_len; *************** *** 4118,4124 **** return FALSE; if (*p == COM_START) { ! if (*(ml_get_curline() + leader1_len) == NUL) return FALSE; if (leader2_flags == NULL || leader2_len == 0) return FALSE; --- 4119,4125 ---- return FALSE; if (*p == COM_START) { ! if (*(ml_get(lnum) + leader1_len) == NUL) return FALSE; if (leader2_flags == NULL || leader2_len == 0) return FALSE; *************** *** 4134,4145 **** * Get current line and next line, compare the leaders. * The first line has to be saved, only one line can be locked at a time. */ ! line1 = vim_strsave(ml_get_curline()); if (line1 != NULL) { for (idx1 = 0; vim_iswhite(line1[idx1]); ++idx1) ; ! line2 = ml_get(curwin->w_cursor.lnum + 1); for (idx2 = 0; idx2 < leader2_len; ++idx2) { if (!vim_iswhite(line2[idx2])) --- 4135,4146 ---- * Get current line and next line, compare the leaders. * The first line has to be saved, only one line can be locked at a time. */ ! line1 = vim_strsave(ml_get(lnum)); if (line1 != NULL) { for (idx1 = 0; vim_iswhite(line1[idx1]); ++idx1) ; ! line2 = ml_get(lnum + 1); for (idx2 = 0; idx2 < leader2_len; ++idx2) { if (!vim_iswhite(line2[idx2])) *************** *** 4379,4385 **** */ if (curwin->w_cursor.lnum >= curbuf->b_ml.ml_line_count #ifdef FEAT_COMMENTS ! || !same_leader(leader_len, leader_flags, next_leader_len, next_leader_flags) #endif ) --- 4380,4387 ---- */ if (curwin->w_cursor.lnum >= curbuf->b_ml.ml_line_count #ifdef FEAT_COMMENTS ! || !same_leader(curwin->w_cursor.lnum, ! leader_len, leader_flags, next_leader_len, next_leader_flags) #endif ) *************** *** 4576,4582 **** return TRUE; /* numbered item starts in "lnum". */ #ifdef FEAT_COMMENTS ! if (!same_leader(leader_len, leader_flags, next_leader_len, next_leader_flags)) return TRUE; /* change of comment leader. */ #endif --- 4578,4584 ---- return TRUE; /* numbered item starts in "lnum". */ #ifdef FEAT_COMMENTS ! if (!same_leader(lnum - 1, leader_len, leader_flags, next_leader_len, next_leader_flags)) return TRUE; /* change of comment leader. */ #endif *** ../vim-6.3a.002/src/version.c Fri May 7 17:06:13 2004 --- src/version.c Sat May 8 12:30:09 2004 *************** *** 643,644 **** --- 643,646 ---- { /* Add new patch number below this line */ + /**/ + 3, /**/ -- hundred-and-one symptoms of being an internet addict: 183. You move your coffeemaker next to your computer. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///