Boolean		addSpace;
bool		addSpace;
VarRESubstitute(word, addSpace, buf, patternp)    struct Name		*word;    Boolean		addSpace;    Buffer		buf;    void		*patternp;{    VarREPattern	*pat;    int 		xrv;    const char		*wp;    char		*rp;    int 		added;#define MAYBE_ADD_SPACE()		\	if (addSpace && !added) 	\	    Buf_AddSpace(buf);		\	added = 1    added = 0;    wp = word->s;    pat = patternp;    if ((pat->flags & (VAR_SUB_ONE|VAR_SUB_MATCHED)) ==	(VAR_SUB_ONE|VAR_SUB_MATCHED))	xrv = REG_NOMATCH;    else {    tryagain:	xrv = regexec(&pat->re, wp, pat->nsub, pat->matches, 0);    }    switch (xrv) {    case 0:	pat->flags |= VAR_SUB_MATCHED;	if (pat->matches[0].rm_so > 0) {	    MAYBE_ADD_SPACE();	    Buf_AddChars(buf, pat->matches[0].rm_so, wp);	}	for (rp = pat->replace; *rp; rp++) {	    if (*rp == '\\' && (rp[1] == '&' || rp[1] == '\\')) {		MAYBE_ADD_SPACE();		Buf_AddChar(buf,rp[1]);		rp++;	    }	    else if (*rp == '&' || (*rp == '\\' && isdigit(rp[1]))) {		int n;		const char *subbuf;		int sublen;		char errstr[3];		if (*rp == '&') {		    n = 0;		    errstr[0] = '&';		    errstr[1] = '\0';		} else {		    n = rp[1] - '0';		    errstr[0] = '\\';		    errstr[1] = rp[1];		    errstr[2] = '\0';		    rp++;		}		if (n > pat->nsub) {		    Error("No subexpression %s", &errstr[0]);		    subbuf = "";		    sublen = 0;		} else if (pat->matches[n].rm_so == -1 &&			   pat->matches[n].rm_eo == -1) {		    Error("No match for subexpression %s", &errstr[0]);		    subbuf = "";		    sublen = 0;		} else {		    subbuf = wp + pat->matches[n].rm_so;		    sublen = pat->matches[n].rm_eo - pat->matches[n].rm_so;		}		if (sublen > 0) {		    MAYBE_ADD_SPACE();		    Buf_AddChars(buf, sublen, subbuf);		}	    } else {		MAYBE_ADD_SPACE();		Buf_AddChar(buf, *rp);	    }	}	wp += pat->matches[0].rm_eo;	if (pat->flags & VAR_SUB_GLOBAL)	    goto tryagain;	if (*wp) {	    MAYBE_ADD_SPACE();	    Buf_AddString(buf, wp);	}	break;    default:	VarREError(xrv, &pat->re, "Unexpected regex error");       /* fall through */    case REG_NOMATCH:	if (*wp) {	    MAYBE_ADD_SPACE();	    Buf_AddString(buf, wp);	}	break;    }    return addSpace||added;}