size_t blen, len, tlen;
size_t blen, len, off, tlen;
argv_fexp(sp, excp, cmd, cmdlen, p, lenp, bpp, blenp, is_bang)	SCR *sp;	EXCMD *excp;	char *cmd, *p, **bpp;	size_t cmdlen, *lenp, *blenp;	int is_bang;{	EX_PRIVATE *exp;	char *bp, *t;	size_t blen, len, tlen;	/* Replace file name characters. */	for (bp = *bpp, blen = *blenp, len = *lenp; cmdlen > 0; --cmdlen, ++cmd)		switch (*cmd) {		case '!':			if (!is_bang)				goto ins_ch;			exp = EXP(sp);			if (exp->lastbcomm == NULL) {				msgq(sp, M_ERR,				    "115|No previous command to replace \"!\"");				return (1);			}			len += tlen = strlen(exp->lastbcomm);			ADD_SPACE_RET(sp, bp, blen, len);			memcpy(p, exp->lastbcomm, tlen);			p += tlen;			F_SET(excp, E_MODIFY);			break;		case '%':			if ((t = sp->frp->name) == NULL) {				msgq(sp, M_ERR,				    "116|No filename to substitute for %%");				return (1);			}			tlen = strlen(t);			len += tlen;			ADD_SPACE_RET(sp, bp, blen, len);			memcpy(p, t, tlen);			p += tlen;			F_SET(excp, E_MODIFY);			break;		case '#':			if ((t = sp->alt_name) == NULL) {				msgq(sp, M_ERR,				    "117|No filename to substitute for #");				return (1);			}			len += tlen = strlen(t);			ADD_SPACE_RET(sp, bp, blen, len);			memcpy(p, t, tlen);			p += tlen;			F_SET(excp, E_MODIFY);			break;		case '\\':			/*			 * QUOTING NOTE:			 *			 * Strip any backslashes that protected the file			 * expansion characters.			 */			if (cmdlen > 1 &&			    (cmd[1] == '%' || cmd[1] == '#' || cmd[1] == '!')) {				++cmd;				--cmdlen;			}			/* FALLTHROUGH */		default:ins_ch:			++len;			ADD_SPACE_RET(sp, bp, blen, len);			*p++ = *cmd;		}	/* Nul termination. */	++len;	ADD_SPACE_RET(sp, bp, blen, len);	*p = '\0';	/* Return the new string length, buffer, buffer length. */	*lenp = len - 1;	*bpp = bp;	*blenp = blen;	return (0);}