0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

updated for version 7.0052

This commit is contained in:
Bram Moolenaar
2005-02-26 23:04:13 +00:00
parent 5313dcb75a
commit 05159a0c6a
57 changed files with 9098 additions and 348 deletions

View File

@@ -2082,25 +2082,38 @@ ExpandBufnames(pat, num_file, file, options)
char_u *p;
int attempt;
regprog_T *prog;
char_u *patc;
*num_file = 0; /* return values in case of FAIL */
*file = NULL;
/*
* attempt == 1: try match with '^', match at start
* attempt == 2: try match without '^', match anywhere
*/
for (attempt = 1; attempt <= 2; ++attempt)
/* Make a copy of "pat" and change "^" to "\(^\|[\/]\)". */
if (*pat == '^')
{
if (attempt == 2)
{
if (*pat != '^') /* there's no '^', no need to try again */
break;
++pat; /* skip the '^' */
}
prog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0);
if (prog == NULL)
patc = alloc((unsigned)STRLEN(pat) + 11);
if (patc == NULL)
return FAIL;
STRCPY(patc, "\\(^\\|[\\/]\\)");
STRCPY(patc + 11, pat + 1);
}
else
patc = pat;
/*
* attempt == 0: try match with '\<', match at start of word
* attempt == 2: try match without '\<', match anywhere
*/
for (attempt = 0; attempt <= 2; attempt += 2)
{
if (attempt == 2 && patc == pat)
break; /* there was no anchor, no need to try again */
prog = vim_regcomp(patc + attempt, RE_MAGIC);
if (prog == NULL)
{
if (patc != pat)
vim_free(patc);
return FAIL;
}
/*
* round == 1: Count the matches.
@@ -2136,6 +2149,8 @@ ExpandBufnames(pat, num_file, file, options)
if (*file == NULL)
{
vim_free(prog);
if (patc != pat)
vim_free(patc);
return FAIL;
}
}
@@ -2145,6 +2160,9 @@ ExpandBufnames(pat, num_file, file, options)
break;
}
if (patc != pat)
vim_free(patc);
*num_file = count;
return (count == 0 ? FAIL : OK);
}