To: vim-dev@vim.org Subject: Patch 6.1.363 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.363 Problem: byte2line() can return one more than the number of lines. Solution: Return -1 if the offset is one byte past the end. Files: src/memline.c *** ../vim61.362/src/memline.c Wed Jan 29 22:08:43 2003 --- src/memline.c Wed Feb 26 12:33:23 2003 *************** *** 4300,4306 **** else *offp = offset - size + len - (text_end - ((dp->db_index[idx - 1]) & DB_INDEX_MASK)); ! return curline + idx - start_idx + extra; } curline = buf->b_ml.ml_locked_high + 1; } --- 4319,4328 ---- else *offp = offset - size + len - (text_end - ((dp->db_index[idx - 1]) & DB_INDEX_MASK)); ! curline += idx - start_idx + extra; ! if (curline > buf->b_ml.ml_line_count) ! return -1; /* exactly one byte beyond the end */ ! return curline; } curline = buf->b_ml.ml_locked_high + 1; } *** ../vim61.362/src/version.c Tue Feb 25 21:50:44 2003 --- src/version.c Wed Feb 26 21:03:52 2003 *************** *** 608,609 **** --- 612,615 ---- { /* Add new patch number below this line */ + /**/ + 363, /**/ -- LAUNCELOT: Isn't there a St. Aaaaarrrrrrggghhh's in Cornwall? ARTHUR: No, that's Saint Ives. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///