To: vim-dev@vim.org Subject: Patch 7.1.258 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 7.1.258 Problem: Crash when doing "d/\n/e" and 'virtualedit' is "all". (Andy Wokula) Solution: Avoid that the column becomes negative. Also fixes other problems with the end of a pattern match is in column zero. (A.Politz) Files: src/search.c *** ../vim-7.1.257/src/search.c Sat Jan 26 21:15:00 2008 --- src/search.c Wed Feb 20 13:22:23 2008 *************** *** 624,630 **** #ifdef FEAT_EVAL submatch = first_submatch(®match); #endif ! /* Line me be past end of buffer for "\n\zs". */ if (lnum + matchpos.lnum > buf->b_ml.ml_line_count) ptr = (char_u *)""; else --- 624,630 ---- #ifdef FEAT_EVAL submatch = first_submatch(®match); #endif ! /* "lnum" may be past end of buffer for "\n\zs". */ if (lnum + matchpos.lnum > buf->b_ml.ml_line_count) ptr = (char_u *)""; else *************** *** 833,853 **** continue; } ! if (options & SEARCH_END && !(options & SEARCH_NOOF)) { pos->lnum = lnum + endpos.lnum; ! pos->col = endpos.col - 1; ! #ifdef FEAT_MBYTE ! if (has_mbyte) { ! /* 'e' offset may put us just below the last line */ ! if (pos->lnum > buf->b_ml.ml_line_count) ! ptr = (char_u *)""; ! else ! ptr = ml_get_buf(buf, pos->lnum, FALSE); ! pos->col -= (*mb_head_off)(ptr, ptr + pos->col); } #endif } else { --- 833,870 ---- continue; } ! /* With the SEARCH_END option move to the last character ! * of the match. Don't do it for an empty match, end ! * should be same as start then. */ ! if (options & SEARCH_END && !(options & SEARCH_NOOF) ! && !(matchpos.lnum == endpos.lnum ! && matchpos.col == endpos.col)) { + /* For a match in the first column, set the position + * on the NUL in the previous line. */ pos->lnum = lnum + endpos.lnum; ! pos->col = endpos.col; ! if (endpos.col == 0) { ! if (pos->lnum > 1) /* just in case */ ! { ! --pos->lnum; ! pos->col = (colnr_T)STRLEN(ml_get_buf(buf, ! pos->lnum, FALSE)); ! } } + else + { + --pos->col; + #ifdef FEAT_MBYTE + if (has_mbyte + && pos->lnum <= buf->b_ml.ml_line_count) + { + ptr = ml_get_buf(buf, pos->lnum, FALSE); + pos->col -= (*mb_head_off)(ptr, ptr + pos->col); + } #endif + } } else { *** ../vim-7.1.257/src/version.c Wed Feb 20 12:43:05 2008 --- src/version.c Wed Feb 20 13:37:32 2008 *************** *** 668,669 **** --- 668,671 ---- { /* Add new patch number below this line */ + /**/ + 258, /**/ -- Micro$oft: where do you want to go today? Linux: where do you want to go tomorrow? FreeBSD: are you guys coming, or what? /// 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 ///