Char    patbuf[MAXPATHLEN + 1];
Char    patbuf[MAXPATHLEN];
static int globexp2(ptr, pattern, pglob, rv)	const Char *ptr, *pattern;	glob_t *pglob;	int *rv;{	int     i;	Char   *lm, *ls;	const Char *pe, *pm, *pl;	Char    patbuf[MAXPATHLEN + 1];	/* copy part up to the brace */	for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++)		continue;	ls = lm;	/* Find the balanced brace */	for (i = 0, pe = ++ptr; *pe; pe++)		if (*pe == LBRACKET) {			/* Ignore everything between [] */			for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++)				continue;			if (*pe == EOS) {				/*				 * We could not find a matching RBRACKET.				 * Ignore and just look for RBRACE				 */				pe = pm;			}		}		else if (*pe == LBRACE)			i++;		else if (*pe == RBRACE) {			if (i == 0)				break;			i--;		}	/* Non matching braces; just glob the pattern */	if (i != 0 || *pe == EOS) {		*rv = glob0(patbuf, pglob);		return 0;	}	for (i = 0, pl = pm = ptr; pm <= pe; pm++) {		switch (*pm) {		case LBRACKET:			/* Ignore everything between [] */			for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++)				continue;			if (*pm == EOS) {				/*				 * We could not find a matching RBRACKET.				 * Ignore and just look for RBRACE				 */				pm = pl;			}			break;		case LBRACE:			i++;			break;		case RBRACE:			if (i) {				i--;				break;			}			/* FALLTHROUGH */		case COMMA:			if (i && *pm == COMMA)				break;			else {				/* Append the current string */				for (lm = ls; (pl < pm); *lm++ = *pl++)					continue;				/*				 * Append the rest of the pattern after the				 * closing brace				 */				for (pl = pe + 1; (*lm++ = *pl++) != EOS;)					continue;				/* Expand the current pattern */#ifdef DEBUG				qprintf("globexp2:", patbuf);#endif				*rv = globexp1(patbuf, pglob);				/* move after the comma, to the next string */				pl = pm + 1;			}			break;		default:			break;		}	}	*rv = 0;	return 0;}