glob2(pathbuf, pathend, pattern, pglob, limitp) Char *pathbuf, *pathend, *pattern;
glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last, pglob, limitp) Char *pathbuf, *pathbuf_last, *pathend, *pathend_last; Char *pattern, *pattern_last;
glob2(pathbuf, pathend, pattern, pglob, limitp)	Char *pathbuf, *pathend, *pattern;	glob_t *pglob;	size_t *limitp;{	struct stat sb;	Char *p, *q;	int anymeta;	/*	 * Loop over pattern segments until end of pattern or until	 * segment with meta character found.	 */	for (anymeta = 0;;) {		if (*pattern == EOS) {		/* End of pattern? */			*pathend = EOS;			if (g_lstat(pathbuf, &sb, pglob))				return(0);			if (((pglob->gl_flags & GLOB_MARK) &&			    pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) ||			    (S_ISLNK(sb.st_mode) &&			    (g_stat(pathbuf, &sb, pglob) == 0) &&			    S_ISDIR(sb.st_mode)))) {				*pathend++ = SEP;				*pathend = EOS;			}			++pglob->gl_matchc;			return(globextend(pathbuf, pglob, limitp));		}		/* Find end of next segment, copy tentatively to pathend. */		q = pathend;		p = pattern;		while (*p != EOS && *p != SEP) {			if (ismeta(*p))				anymeta = 1;			*q++ = *p++;		}		if (!anymeta) {		/* No expansion, do next segment. */			pathend = q;			pattern = p;			while (*pattern == SEP)				*pathend++ = *pattern++;		} else			/* Need expansion, recurse. */			return(glob3(pathbuf, pathend, pattern, p, pglob,			    limitp));	}	/* NOTREACHED */}