Char *b;
Char *b, *eb;
globtilde(pattern, patbuf, pglob)	const Char *pattern;	Char *patbuf;	glob_t *pglob;{	struct passwd *pwd;	char *h;	const Char *p;	Char *b;	if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))		return pattern;	/* Copy up to the end of the string or / */	for (p = pattern + 1, h = (char *) patbuf; *p && *p != SLASH; 	     *h++ = *p++)		continue;	*h = EOS;	if (((char *) patbuf)[0] == EOS) {		/* 		 * handle a plain ~ or ~/ by expanding $HOME 		 * first and then trying the password file		 */		if (issetugid() != 0 || (h = getenv("HOME")) == NULL) {			if ((pwd = getpwuid(getuid())) == NULL)				return pattern;			else				h = pwd->pw_dir;		} else {			if (strlen(h) >= MAXPATHLEN-1)				return pattern;		}	}	else {		/*		 * Expand a ~user		 */		if ((pwd = getpwnam((char*) patbuf)) == NULL)			return pattern;		else			h = pwd->pw_dir;	}	/* Copy the home directory */	for (b = patbuf; *h; *b++ = *h++)		continue;		/* Append the rest of the pattern */	while ((*b++ = *p++) != EOS)		continue;	return patbuf;}