#include "sh.h"
RCSID("$Id: sh.exec.c,v 3.63 2004/11/23 02:10:48 christos Exp $")
#include "tc.h"
#include "tw.h"
#ifdef WINNT_NATIVE
#include <nt.const.h>
#endif
#ifndef OLDHASH
# define FASTHASH
#endif
static char *exerr;
static Char *expath;
#define BITS_PER_BYTE 8
#ifdef FASTHASH
# define HSHMUL 241
static unsigned long *xhash = NULL;
static unsigned int hashlength = 0, uhashlength = 0;
static unsigned int hashwidth = 0, uhashwidth = 0;
static int hashdebug = 0;
# define hash(a, b) (((a) * HSHMUL + (b)) % (hashlength))
# define widthof(t) (sizeof(t) * BITS_PER_BYTE)
# define tbit(f, i, t) (((t *) xhash)[(f)] & \
(1UL << (i & (widthof(t) - 1))))
# define tbis(f, i, t) (((t *) xhash)[(f)] |= \
(1UL << (i & (widthof(t) - 1))))
# define cbit(f, i) tbit(f, i, unsigned char)
# define cbis(f, i) tbis(f, i, unsigned char)
# define sbit(f, i) tbit(f, i, unsigned short)
# define sbis(f, i) tbis(f, i, unsigned short)
# define ibit(f, i) tbit(f, i, unsigned int)
# define ibis(f, i) tbis(f, i, unsigned int)
# define lbit(f, i) tbit(f, i, unsigned long)
# define lbis(f, i) tbis(f, i, unsigned long)
# define bit(f, i) (hashwidth==sizeof(unsigned char) ? cbit(f,i) : \
((hashwidth==sizeof(unsigned short) ? sbit(f,i) : \
((hashwidth==sizeof(unsigned int) ? ibit(f,i) : \
lbit(f,i))))))
# define bis(f, i) (hashwidth==sizeof(unsigned char) ? cbis(f,i) : \
((hashwidth==sizeof(unsigned short) ? sbis(f,i) : \
((hashwidth==sizeof(unsigned int) ? ibis(f,i) : \
lbis(f,i))))))
#else
# define HSHSIZ 8192
# define HSHMASK (HSHSIZ - 1)
# define HSHMUL 243
static char xhash[HSHSIZ / BITS_PER_BYTE];
# define hash(a, b) (((a) * HSHMUL + (b)) & HSHMASK)
# define bit(h, b) ((h)[(b) >> 3] & 1 << ((b) & 7))
# define bis(h, b) ((h)[(b) >> 3] |= 1 << ((b) & 7))
#endif
#ifdef VFORK
static int hits, misses;
#endif
static Char *justabs[] = {STRNULL, 0};
static void pexerr __P((void));
static void texec __P((Char *, Char **));
int hashname __P((Char *));
static int iscommand __P((Char *));
void
doexec(t, do_glob)
struct command *t;
int do_glob;
{
Char *dp, **pv, **av, *sav;
struct varent *v;
int slash;
int hashval, i;
Char *blk[2];
blk[0] = t->t_dcom[0];
blk[1] = 0;
gflag = 0;
if (do_glob)
tglob(blk);
if (gflag) {
pv = globall(blk);
if (pv == 0) {
setname(short2str(blk[0]));
stderror(ERR_NAME | ERR_NOMATCH);
}
gargv = 0;
}
else
pv = saveblk(blk);
trim(pv);
exerr = 0;
expath = Strsave(pv[0]);
#ifdef VFORK
Vexpath = expath;
#endif
v = adrof(STRpath);
if (v == 0 && expath[0] != '/' && expath[0] != '.') {
blkfree(pv);
pexerr();
}
slash = any(short2str(expath), '/');
gflag = 0;
av = &t->t_dcom[1];
if (do_glob)
tglob(av);
if (gflag) {
av = globall(av);
if (av == 0) {
blkfree(pv);
setname(short2str(expath));
stderror(ERR_NAME | ERR_NOMATCH);
}
gargv = 0;
}
else
av = saveblk(av);
blkfree(t->t_dcom);
t->t_dcom = blkspl(pv, av);
xfree((ptr_t) pv);
xfree((ptr_t) av);
av = t->t_dcom;
trim(av);
if (*av == NULL || **av == '\0')
pexerr();
xechoit(av);
#ifdef CLOSE_ON_EXEC
SHIN = 0;
SHOUT = 1;
SHDIAG = 2;
OLDSTD = 0;
isoutatty = isatty(SHOUT);
isdiagatty = isatty(SHDIAG);
#else
closech();
#endif
#ifdef BSDSIGS
(void) sigsetmask((sigmask_t) 0);
#else
(void) sigrelse(SIGINT);
(void) sigrelse(SIGCHLD);
#endif
if (v == NULL || v->vec == NULL || v->vec[0] == NULL || slash)
pv = justabs;
else
pv = v->vec;
sav = Strspl(STRslash, *av);
#ifdef VFORK
Vsav = sav;
#endif
hashval = havhash ? hashname(*av) : 0;
i = 0;
#ifdef VFORK
hits++;
#endif
do {
if (!slash && ABSOLUTEP(pv[0]) && havhash) {
#ifdef FASTHASH
if (!bit(hashval, i))
goto cont;
#else
int hashval1 = hash(hashval, i);
if (!bit(xhash, hashval1))
goto cont;
#endif
}
if (pv[0][0] == 0 || eq(pv[0], STRdot))
{
#ifdef COHERENT
if (t->t_dflg & F_AMPERSAND) {
# ifdef JOBDEBUG
xprintf("set SIGINT to SIG_IGN\n");
xprintf("set SIGQUIT to SIG_DFL\n");
# endif
(void) signal(SIGINT,SIG_IGN);
(void) signal(SIGQUIT,SIG_DFL);
}
if (gointr && eq(gointr, STRminus)) {
# ifdef JOBDEBUG
xprintf("set SIGINT to SIG_IGN\n");
xprintf("set SIGQUIT to SIG_IGN\n");
# endif
(void) signal(SIGINT,SIG_IGN);
(void) signal(SIGQUIT,SIG_IGN);
}
#endif
texec(*av, av);
}
else {
dp = Strspl(*pv, sav);
#ifdef VFORK
Vdp = dp;
#endif
#ifdef COHERENT
if ((t->t_dflg & F_AMPERSAND)) {
# ifdef JOBDEBUG
xprintf("set SIGINT to SIG_IGN\n");
# endif
(void) signal(SIGINT,SIG_IGN);
}
if (gointr && eq(gointr,STRminus)) {
# ifdef JOBDEBUG
xprintf("set SIGINT to SIG_IGN\n");
xprintf("set SIGQUIT to SIG_IGN\n");
# endif
(void) signal(SIGINT,SIG_IGN);
(void) signal(SIGQUIT,SIG_IGN);
}
#endif
texec(dp, av);
#ifdef VFORK
Vdp = 0;
#endif
xfree((ptr_t) dp);
}
#ifdef VFORK
misses++;
#endif
cont:
pv++;
i++;
} while (*pv);
#ifdef VFORK
hits--;
Vsav = 0;
#endif
xfree((ptr_t) sav);
pexerr();
}
static void
pexerr()
{
if (expath) {
setname(short2str(expath));
#ifdef VFORK
Vexpath = 0;
#endif
xfree((ptr_t) expath);
expath = 0;
}
else
setname("");
if (exerr)
stderror(ERR_NAME | ERR_STRING, exerr);
stderror(ERR_NAME | ERR_COMMAND);
}
static void
texec(sf, st)
Char *sf;
Char **st;
{
char **t;
char *f;
struct varent *v;
Char **vp;
Char *lastsh[2];
char pref[2];
int fd;
Char *st0, **ost;
t = short2blk(st);
f = short2str(sf);
#ifdef VFORK
Vt = t;
#endif
errno = 0;
#ifdef apollo
{
struct stat stb;
if (stat(f, &stb) == 0 && S_ISDIR(stb.st_mode))
errno = EISDIR;
}
if (errno == 0)
#endif
{
#ifdef ISC_POSIX_EXEC_BUG
__setostype(0);
#endif
(void) execv(f, t);
#ifdef ISC_POSIX_EXEC_BUG
__setostype(1);
#endif
}
#ifdef VFORK
Vt = 0;
#endif
blkfree((Char **) t);
switch (errno) {
case ENOEXEC:
#ifdef WINNT_NATIVE
nt_feed_to_cmd(f,t);
#endif
if ((fd = open(f, O_RDONLY|O_LARGEFILE)) != -1) {
int nread;
#ifdef O_TEXT
setmode(fd, O_TEXT);
#endif
if ((nread = read(fd, (char *) pref, 2)) == 2) {
if (!isprint((unsigned char)pref[0]) &&
(pref[0] != '\n' && pref[0] != '\t')) {
(void) close(fd);
stderror(ERR_ARCH, f, strerror(errno));
}
}
else if (nread < 0 && errno != EINTR) {
#ifdef convex
stderror(ERR_SYSTEM, f, strerror(errno));
#endif
}
#ifdef _PATH_BSHELL
else {
pref[0] = '#';
pref[1] = '\0';
}
#endif
}
#ifdef HASHBANG
if (fd == -1 ||
pref[0] != '#' || pref[1] != '!' || hashbang(fd, &vp) == -1) {
#endif
v = adrof1(STRshell, &aliases);
if (v == NULL || v->vec == NULL) {
vp = lastsh;
vp[0] = adrof(STRshell) ? varval(STRshell) : STR_SHELLPATH;
vp[1] = NULL;
#ifdef _PATH_BSHELL
if (fd != -1
# ifndef ISC
&& pref[0] != '#'
# endif
)
vp[0] = STR_BSHELL;
#endif
vp = saveblk(vp);
}
else
vp = saveblk(v->vec);
#ifdef HASHBANG
}
#endif
if (fd != -1)
(void) close(fd);
st0 = st[0];
st[0] = sf;
ost = st;
st = blkspl(vp, st);
ost[0] = st0;
sf = *st;
t = short2blk(st);
f = short2str(sf);
xfree((ptr_t) st);
blkfree((Char **) vp);
#ifdef VFORK
Vt = t;
#endif
#ifdef ISC_POSIX_EXEC_BUG
__setostype(0);
#endif
(void) execv(f, t);
#ifdef ISC_POSIX_EXEC_BUG
__setostype(1);
#endif
#ifdef VFORK
Vt = 0;
#endif
blkfree((Char **) t);
stderror(ERR_SYSTEM, f, strerror(errno));
break;
case ENOMEM:
stderror(ERR_SYSTEM, f, strerror(errno));
break;
#ifdef _IBMR2
case 0:
#endif
case ENOENT:
break;
default:
if (exerr == 0) {
exerr = strerror(errno);
if (expath)
xfree((ptr_t) expath);
expath = Strsave(sf);
#ifdef VFORK
Vexpath = expath;
#endif
}
break;
}
}
void
execash(t, kp)
Char **t;
struct command *kp;
{
int saveIN, saveOUT, saveDIAG, saveSTD;
int oSHIN;
int oSHOUT;
int oSHDIAG;
int oOLDSTD;
jmp_buf_t osetexit;
int my_reenter;
int odidfds;
#ifndef CLOSE_ON_EXEC
int odidcch;
#endif
signalfun_t osigint, osigquit, osigterm;
USE(t);
if (chkstop == 0 && setintr)
panystop(0);
rechist(NULL, adrof(STRsavehist) != NULL);
osigint = signal(SIGINT, parintr);
osigquit = signal(SIGQUIT, parintr);
osigterm = signal(SIGTERM, parterm);
odidfds = didfds;
#ifndef CLOSE_ON_EXEC
odidcch = didcch;
#endif
oSHIN = SHIN;
oSHOUT = SHOUT;
oSHDIAG = SHDIAG;
oOLDSTD = OLDSTD;
(void)close_on_exec (saveIN = dcopy(SHIN, -1), 1);
(void)close_on_exec (saveOUT = dcopy(SHOUT, -1), 1);
(void)close_on_exec (saveDIAG = dcopy(SHDIAG, -1), 1);
(void)close_on_exec (saveSTD = dcopy(OLDSTD, -1), 1);
lshift(kp->t_dcom, 1);
getexit(osetexit);
#ifdef cray
my_reenter = 1;
if (setexit() == 0) {
my_reenter = 0;
#else
if ((my_reenter = setexit()) == 0) {
#endif
(void)close_on_exec (SHIN = dcopy(0, -1), 1);
(void)close_on_exec (SHOUT = dcopy(1, -1), 1);
(void)close_on_exec (SHDIAG = dcopy(2, -1), 1);
#ifndef CLOSE_ON_EXEC
didcch = 0;
#endif
didfds = 0;
shlvl(-1);
#ifdef WINNT_NATIVE
__nt_really_exec=1;
#endif
doexec(kp, 1);
}
(void) sigset(SIGINT, osigint);
(void) sigset(SIGQUIT, osigquit);
(void) sigset(SIGTERM, osigterm);
doneinp = 0;
#ifndef CLOSE_ON_EXEC
didcch = odidcch;
#endif
didfds = odidfds;
(void) close(SHIN);
(void) close(SHOUT);
(void) close(SHDIAG);
(void) close(OLDSTD);
(void)close_on_exec(SHIN = dmove(saveIN, oSHIN), 1);
(void)close_on_exec(SHOUT = dmove(saveOUT, oSHOUT), 1);
(void)close_on_exec(SHDIAG = dmove(saveDIAG, oSHDIAG), 1);
(void)close_on_exec(OLDSTD = dmove(saveSTD, oOLDSTD), 1);
resexit(osetexit);
if (my_reenter)
stderror(ERR_SILENT);
}
void
xechoit(t)
Char **t;
{
if (adrof(STRecho)) {
int odidfds = didfds;
flush();
haderr = 1;
didfds = 0;
blkpr(t), xputchar('\n');
flush();
didfds = odidfds;
haderr = 0;
}
}
void
dohash(vv, c)
Char **vv;
struct command *c;
{
#ifdef COMMENT
struct stat stb;
#endif
DIR *dirp;
struct dirent *dp;
int i = 0;
struct varent *v = adrof(STRpath);
Char **pv;
int hashval;
#ifdef WINNT_NATIVE
int is_windir;
USE(hashval);
#endif
USE(c);
#ifdef FASTHASH
if (vv && vv[1]) {
uhashlength = atoi(short2str(vv[1]));
if (vv[2]) {
uhashwidth = atoi(short2str(vv[2]));
if ((uhashwidth != sizeof(unsigned char)) &&
(uhashwidth != sizeof(unsigned short)) &&
(uhashwidth != sizeof(unsigned long)))
uhashwidth = 0;
if (vv[3])
hashdebug = atoi(short2str(vv[3]));
}
}
if (uhashwidth)
hashwidth = uhashwidth;
else {
hashwidth = 0;
if (v == NULL)
return;
for (pv = v->vec; pv && *pv; pv++, hashwidth++)
continue;
if (hashwidth <= widthof(unsigned char))
hashwidth = sizeof(unsigned char);
else if (hashwidth <= widthof(unsigned short))
hashwidth = sizeof(unsigned short);
else if (hashwidth <= widthof(unsigned int))
hashwidth = sizeof(unsigned int);
else
hashwidth = sizeof(unsigned long);
}
if (uhashlength)
hashlength = uhashlength;
else
hashlength = hashwidth * (8*64);
if (xhash)
xfree((ptr_t) xhash);
xhash = (unsigned long *) xcalloc((size_t) (hashlength * hashwidth),
(size_t) 1);
#endif
(void) getusername(NULL);
tw_cmd_free();
havhash = 1;
if (v == NULL)
return;
for (pv = v->vec; pv && *pv; pv++, i++) {
if (!ABSOLUTEP(pv[0]))
continue;
dirp = opendir(short2str(*pv));
if (dirp == NULL)
continue;
#ifdef COMMENT
if (fstat(dirp->dd_fd, &stb) < 0 || !S_ISDIR(stb.st_mode)) {
(void) closedir(dirp);
continue;
}
#endif
#ifdef WINNT_NATIVE
is_windir = nt_check_if_windir(short2str(*pv));
#endif
while ((dp = readdir(dirp)) != NULL) {
if (dp->d_ino == 0)
continue;
if (dp->d_name[0] == '.' &&
(dp->d_name[1] == '\0' ||
(dp->d_name[1] == '.' && dp->d_name[2] == '\0')))
continue;
#ifdef WINNT_NATIVE
nt_check_name_and_hash(is_windir, dp->d_name, i);
#else
#if defined(_UWIN) || defined(__CYGWIN__)
{
size_t ext = strlen(dp->d_name) - 4;
if ((ext > 0) && (strcasecmp(&dp->d_name[ext], ".exe") == 0 ||
strcasecmp(&dp->d_name[ext], ".bat") == 0 ||
strcasecmp(&dp->d_name[ext], ".com") == 0))
{
dp->d_name[ext] = '\0';
#if defined(__CYGWIN__)
strlwr(dp->d_name);
#endif
}
}
#endif
# ifdef FASTHASH
hashval = hashname(str2short(dp->d_name));
bis(hashval, i);
if (hashdebug & 1)
xprintf(CGETS(13, 1, "hash=%-4d dir=%-2d prog=%s\n"),
hashname(str2short(dp->d_name)), i, dp->d_name);
# else
hashval = hash(hashname(str2short(dp->d_name)), i);
bis(xhash, hashval);
# endif
#endif
}
(void) closedir(dirp);
}
}
void
dounhash(v, c)
Char **v;
struct command *c;
{
USE(c);
USE(v);
havhash = 0;
#ifdef FASTHASH
if (xhash) {
xfree((ptr_t) xhash);
xhash = NULL;
}
#endif
}
void
hashstat(v, c)
Char **v;
struct command *c;
{
USE(c);
USE(v);
#ifdef FASTHASH
if (havhash && hashlength && hashwidth)
xprintf(CGETS(13, 2, "%d hash buckets of %d bits each\n"),
hashlength, hashwidth*8);
if (hashdebug)
xprintf(CGETS(13, 3, "debug mask = 0x%08x\n"), hashdebug);
#endif
#ifdef VFORK
if (hits + misses)
xprintf(CGETS(13, 4, "%d hits, %d misses, %d%%\n"),
hits, misses, 100 * hits / (hits + misses));
#endif
}
int
hashname(cp)
Char *cp;
{
unsigned long h;
for (h = 0; *cp; cp++)
h = hash(h, *cp);
return ((int) h);
}
static int
iscommand(name)
Char *name;
{
Char **pv;
Char *sav;
struct varent *v;
int slash = any(short2str(name), '/');
int hashval, i;
v = adrof(STRpath);
if (v == NULL || v->vec == NULL || v->vec[0] == NULL || slash)
pv = justabs;
else
pv = v->vec;
sav = Strspl(STRslash, name);
hashval = havhash ? hashname(name) : 0;
i = 0;
do {
if (!slash && ABSOLUTEP(pv[0]) && havhash) {
#ifdef FASTHASH
if (!bit(hashval, i))
goto cont;
#else
int hashval1 = hash(hashval, i);
if (!bit(xhash, hashval1))
goto cont;
#endif
}
if (pv[0][0] == 0 || eq(pv[0], STRdot)) {
if (executable(NULL, name, 0)) {
xfree((ptr_t) sav);
return i + 1;
}
}
else {
if (executable(*pv, sav, 0)) {
xfree((ptr_t) sav);
return i + 1;
}
}
cont:
pv++;
i++;
} while (*pv);
xfree((ptr_t) sav);
return 0;
}
#ifndef WINNT_NATIVE
int
executable(dir, name, dir_ok)
Char *dir, *name;
int dir_ok;
{
struct stat stbuf;
Char path[MAXPATHLEN + 1];
char *strname;
(void) memset(path, 0, sizeof(path));
if (dir && *dir) {
copyn(path, dir, MAXPATHLEN);
catn(path, name, MAXPATHLEN);
strname = short2str(path);
}
else
strname = short2str(name);
return (stat(strname, &stbuf) != -1 &&
((dir_ok && S_ISDIR(stbuf.st_mode)) ||
(S_ISREG(stbuf.st_mode) &&
(stbuf.st_mode & (S_IXOTH | S_IXGRP | S_IXUSR)) &&
access(strname, X_OK) == 0
)));
}
#endif
int
tellmewhat(lexp, str)
struct wordent *lexp;
Char *str;
{
int i;
struct biltins *bptr;
struct wordent *sp = lexp->next;
int aliased = 0, found;
Char *s0, *s1, *s2, *cmd;
Char qc;
if (adrof1(sp->word, &aliases)) {
alias(lexp);
sp = lexp->next;
aliased = 1;
}
s0 = sp->word;
if ((*(sp->word) & (QUOTE | TRIM)) == QUOTE)
(sp->word)++;
s1 = s2 = sp->word;
while (*s2)
switch (*s2) {
case '\'':
case '"':
qc = *s2++;
while (*s2 && *s2 != qc)
*s1++ = *s2++ | QUOTE;
if (*s2)
s2++;
break;
case '\\':
if (*++s2)
*s1++ = *s2++ | QUOTE;
break;
default:
*s1++ = *s2++;
}
*s1 = '\0';
for (bptr = bfunc; bptr < &bfunc[nbfunc]; bptr++) {
if (eq(sp->word, str2short(bptr->bname))) {
if (str == NULL) {
if (aliased)
prlex(lexp);
xprintf(CGETS(13, 5, "%S: shell built-in command.\n"),
sp->word);
flush();
}
else
(void) Strcpy(str, sp->word);
sp->word = s0;
return TRUE;
}
}
#ifdef WINNT_NATIVE
for (bptr = nt_bfunc; bptr < &nt_bfunc[nt_nbfunc]; bptr++) {
if (eq(sp->word, str2short(bptr->bname))) {
if (str == NULL) {
if (aliased)
prlex(lexp);
xprintf(CGETS(13, 5, "%S: shell built-in command.\n"),
sp->word);
flush();
}
else
(void) Strcpy(str, sp->word);
sp->word = s0;
return TRUE;
}
}
#endif
sp->word = cmd = globone(sp->word, G_IGNORE);
if ((i = iscommand(sp->word)) != 0) {
Char **pv;
struct varent *v;
int slash = any(short2str(sp->word), '/');
v = adrof(STRpath);
if (v == NULL || v->vec == NULL || v->vec[0] == NULL || slash)
pv = justabs;
else
pv = v->vec;
while (--i)
pv++;
if (pv[0][0] == 0 || eq(pv[0], STRdot)) {
if (!slash) {
sp->word = Strspl(STRdotsl, sp->word);
prlex(lexp);
xfree((ptr_t) sp->word);
}
else
prlex(lexp);
}
else {
s1 = Strspl(*pv, STRslash);
sp->word = Strspl(s1, sp->word);
xfree((ptr_t) s1);
if (str == NULL)
prlex(lexp);
else
(void) Strcpy(str, sp->word);
xfree((ptr_t) sp->word);
}
found = 1;
}
else {
if (str == NULL) {
if (aliased)
prlex(lexp);
xprintf(CGETS(13, 6, "%S: Command not found.\n"), sp->word);
flush();
}
else
(void) Strcpy(str, sp->word);
found = 0;
}
sp->word = s0;
xfree((ptr_t) cmd);
return found;
}
void
dowhere(v, c)
Char **v;
struct command *c;
{
int found = 1;
USE(c);
for (v++; *v; v++)
found &= find_cmd(*v, 1);
if (!found)
set(STRstatus, Strsave(STR1), VAR_READWRITE);
}
int
find_cmd(cmd, prt)
Char *cmd;
int prt;
{
struct varent *var;
struct biltins *bptr;
Char **pv;
Char *sv;
int hashval, i, ex, rval = 0;
if (prt && any(short2str(cmd), '/')) {
xprintf(CGETS(13, 7, "where: / in command makes no sense\n"));
return rval;
}
if (prt && adrof1(cmd, &aliases)) {
if ((var = adrof1(cmd, &aliases)) != NULL) {
xprintf(CGETS(13, 8, "%S is aliased to "), cmd);
if (var->vec != NULL)
blkpr(var->vec);
xputchar('\n');
rval = 1;
}
}
for (bptr = bfunc; bptr < &bfunc[nbfunc]; bptr++) {
if (eq(cmd, str2short(bptr->bname))) {
rval = 1;
if (prt)
xprintf(CGETS(13, 9, "%S is a shell built-in\n"), cmd);
else
return rval;
}
}
#ifdef WINNT_NATIVE
for (bptr = nt_bfunc; bptr < &nt_bfunc[nt_nbfunc]; bptr++) {
if (eq(cmd, str2short(bptr->bname))) {
rval = 1;
if (prt)
xprintf(CGETS(13, 9, "%S is a shell built-in\n"), cmd);
else
return rval;
}
}
#endif
if ((var = adrof(STRpath)) == NULL)
return rval;
hashval = havhash ? hashname(cmd) : 0;
sv = Strspl(STRslash, cmd);
for (pv = var->vec, i = 0; pv && *pv; pv++, i++) {
if (havhash && !eq(*pv, STRdot)) {
#ifdef FASTHASH
if (!bit(hashval, i))
continue;
#else
int hashval1 = hash(hashval, i);
if (!bit(xhash, hashval1))
continue;
#endif
}
ex = executable(*pv, sv, 0);
#ifdef FASTHASH
if (!ex && (hashdebug & 2)) {
xprintf(CGETS(13, 10, "hash miss: "));
ex = 1;
}
#endif
if (ex) {
rval = 1;
if (prt) {
xprintf("%S/", *pv);
xprintf("%S\n", cmd);
}
else
return rval;
}
}
xfree((ptr_t) sv);
return rval;
}
#ifdef WINNT_NATIVE
int hashval_extern(cp)
Char *cp;
{
return havhash?hashname(cp):0;
}
int bit_extern(val,i)
int val;
int i;
{
return bit(val,i);
}
void bis_extern(val,i)
int val;
int i;
{
bis(val,i);
}
#endif