int i, j;
char_u *p1;
char_u *p2;
- int oldlen;
int difflen;
int v;
out_flush();
i = (int)(xp->xp_pattern - ccline.cmdbuff);
- oldlen = ccline.cmdpos - i;
+ xp->xp_pattern_len = ccline.cmdpos - i;
if (type == WILD_NEXT || type == WILD_PREV)
{
/*
* Translate string into pattern and expand it.
*/
- if ((p1 = addstar(&ccline.cmdbuff[i], oldlen, xp->xp_context)) == NULL)
+ if ((p1 = addstar(xp->xp_pattern, xp->xp_pattern_len,
+ xp->xp_context)) == NULL)
p2 = NULL;
else
{
- p2 = ExpandOne(xp, p1, vim_strnsave(&ccline.cmdbuff[i], oldlen),
+ p2 = ExpandOne(xp, p1,
+ vim_strnsave(&ccline.cmdbuff[i], xp->xp_pattern_len),
WILD_HOME_REPLACE|WILD_ADD_SLASH|WILD_SILENT|WILD_ESCAPE
|options, type);
vim_free(p1);
/* longest match: make sure it is not shorter (happens with :help */
if (p2 != NULL && type == WILD_LONGEST)
{
- for (j = 0; j < oldlen; ++j)
+ for (j = 0; j < xp->xp_pattern_len; ++j)
if (ccline.cmdbuff[i + j] == '*'
|| ccline.cmdbuff[i + j] == '?')
break;
if (p2 != NULL && !got_int)
{
- difflen = (int)STRLEN(p2) - oldlen;
+ difflen = (int)STRLEN(p2) - xp->xp_pattern_len;
if (ccline.cmdlen + difflen > ccline.cmdbufflen - 4)
{
v = realloc_cmdbuff(ccline.cmdlen + difflen);
expand_T *xp;
{
xp->xp_pattern = NULL;
+ xp->xp_pattern_len = 0;
xp->xp_backslash = XP_BS_NONE;
#ifndef BACKSLASH_IN_FILENAME
xp->xp_shell = FALSE;
}
/* add star to file name, or convert to regexp if not exp. files. */
- file_str = addstar(xp->xp_pattern,
- (int)(str + col - xp->xp_pattern), xp->xp_context);
+ xp->xp_pattern_len = (int)(str + col - xp->xp_pattern);
+ file_str = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
if (file_str == NULL)
return EXPAND_UNSUCCESSFUL;
sprintf((char *)num, "%d", ccline.cmdpos);
args[1] = ccline.cmdbuff;
}
- args[0] = xp->xp_pattern;
+ args[0] = vim_strnsave(xp->xp_pattern, xp->xp_pattern_len);
args[2] = num;
/* Save the cmdline, we don't know what the function may do. */
if (ccline.cmdbuff != NULL)
ccline.cmdbuff[ccline.cmdlen] = keep;
+ vim_free(args[0]);
return ret;
}