To: vim-dev@vim.org Subject: Patch 6.0.131 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.131 Problem: When using bufname() and there are two matches for listed buffers and one match for an unlisted buffer, the unlisted buffer is used. (Aric Blumer) Solution: When there is a match with a listed buffer, don't check for unlisted buffers. Files: src/buffer.c *** ../vim60.130/src/buffer.c Sat Jan 12 16:39:27 2002 --- src/buffer.c Mon Jan 14 12:43:09 2002 *************** *** 1636,1646 **** } /* ! * Try four ways of matching: * attempt == 0: without '^' or '$' (at any position) * attempt == 1: with '^' at start (only at postion 0) * attempt == 2: with '$' at end (only match at end) * attempt == 3: with '^' at start and '$' at end (only full match) */ else { --- 1636,1648 ---- } /* ! * Try four ways of matching a listed buffer: * attempt == 0: without '^' or '$' (at any position) * attempt == 1: with '^' at start (only at postion 0) * attempt == 2: with '$' at end (only match at end) * attempt == 3: with '^' at start and '$' at end (only full match) + * Repeat this for finding an unlisted buffer if there was no matching + * listed buffer. */ else { *************** *** 1650,1675 **** patend = pat + STRLEN(pat) - 1; toggledollar = (patend > pat && *patend == '$'); ! for (attempt = 0; attempt <= 3; ++attempt) { ! /* may add '^' and '$' */ ! if (toggledollar) ! *patend = (attempt < 2) ? NUL : '$'; /* add/remove '$' */ ! p = pat; ! if (*p == '^' && !(attempt & 1)) /* add/remove '^' */ ! ++p; ! prog = vim_regcomp(p, (int)p_magic); ! if (prog == NULL) { ! vim_free(pat); ! return -1; ! } - /* First try finding a listed buffer, if not found and "unlisted" - * is TRUE, try finding an unlisted buffer. */ - find_listed = TRUE; - for (;;) - { for (buf = firstbuf; buf != NULL; buf = buf->b_next) if (buf->b_p_bl == find_listed #ifdef FEAT_DIFF --- 1652,1677 ---- patend = pat + STRLEN(pat) - 1; toggledollar = (patend > pat && *patend == '$'); ! /* First try finding a listed buffer. If not found and "unlisted" ! * is TRUE, try finding an unlisted buffer. */ ! find_listed = TRUE; ! for (;;) { ! for (attempt = 0; attempt <= 3; ++attempt) { ! /* may add '^' and '$' */ ! if (toggledollar) ! *patend = (attempt < 2) ? NUL : '$'; /* add/remove '$' */ ! p = pat; ! if (*p == '^' && !(attempt & 1)) /* add/remove '^' */ ! ++p; ! prog = vim_regcomp(p, (int)p_magic); ! if (prog == NULL) ! { ! vim_free(pat); ! return -1; ! } for (buf = firstbuf; buf != NULL; buf = buf->b_next) if (buf->b_p_bl == find_listed #ifdef FEAT_DIFF *************** *** 1684,1698 **** } match = buf->b_fnum; /* remember first match */ } ! if (!unlisted || !find_listed || match >= 0) break; - find_listed = FALSE; } ! vim_free(prog); ! if (match >= 0) /* found one match */ break; } vim_free(pat); } --- 1686,1704 ---- } match = buf->b_fnum; /* remember first match */ } ! ! vim_free(prog); ! if (match >= 0) /* found one match */ break; } ! /* Only search for unlisted buffers if there was no match with ! * a listed buffer. */ ! if (!unlisted || !find_listed || match != -1) break; + find_listed = FALSE; } + vim_free(pat); } *** ../vim60.130/src/version.c Sun Jan 13 20:44:03 2002 --- src/version.c Mon Jan 14 12:46:18 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 131, /**/ -- Are leaders born or made? And if they're made, can we return them under warranty? (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///