+/* Also by:
+ * Andreas Luik <luik@isaak.isa.de>
+ * I S A GmbH - Informationssysteme fuer computerintegrierte Automatisierung
+ * Azenberstr. 35
+ * D-7000 Stuttgart 1
+ * West-Germany
+ * is the executable() routine below and changes to iscommand().
+ * Thanks again!!
+ */
+
+/*
+ * executable() examines the pathname obtained by concatenating dir and name
+ * (dir may be NULL), and returns 1 either if it is executable by us, or
+ * if dir_ok is set and the pathname refers to a directory.
+ * This is a bit kludgy, but in the name of optimization...
+ */
+static int
+executable(dir, name, dir_ok)
+ Char *dir, *name;
+ bool dir_ok;
+{
+ struct stat stbuf;
+ Char path[MAXPATHLEN + 1], *dp, *sp;
+ char *strname;
+
+ if (dir && *dir) {
+ for (dp = path, sp = dir; *sp; *dp++ = *sp++)
+ if (dp == &path[MAXPATHLEN + 1]) {
+ *--dp = '\0';
+ break;
+ }
+ for (sp = name; *sp; *dp++ = *sp++)
+ if (dp == &path[MAXPATHLEN + 1]) {
+ *--dp = '\0';
+ break;
+ }
+ *dp = '\0';
+ strname = short2str(path);
+ }
+ else
+ strname = short2str(name);
+ return (stat(strname, &stbuf) != -1 &&
+ ((S_ISREG(stbuf.st_mode) &&
+ /* save time by not calling access() in the hopeless case */
+ (stbuf.st_mode & (S_IXOTH | S_IXGRP | S_IXUSR)) &&
+ access(strname, X_OK) == 0) ||
+ (dir_ok && S_ISDIR(stbuf.st_mode))));
+}
+
+/* The dowhich() is by:
+ * Andreas Luik <luik@isaak.isa.de>
+ * I S A GmbH - Informationssysteme fuer computerintegrierte Automatisierung
+ * Azenberstr. 35
+ * D-7000 Stuttgart 1
+ * West-Germany
+ * Thanks!!
+ */
+/*ARGSUSED*/
+void
+dowhich(v, c)
+ register Char **v;
+ struct command *c;
+{
+ struct wordent lex[3];
+ struct varent *vp;
+
+ lex[0].next = &lex[1];
+ lex[1].next = &lex[2];
+ lex[2].next = &lex[0];
+
+ lex[0].prev = &lex[2];
+ lex[1].prev = &lex[0];
+ lex[2].prev = &lex[1];
+
+ lex[0].word = STRNULL;
+ lex[2].word = STRret;
+
+ while (*++v) {
+ if (vp = adrof1(*v, &aliases)) {
+ (void) fprintf(cshout, "%s: \t aliased to ", vis_str(*v));
+ blkpr(cshout, vp->vec);
+ (void) fputc('\n', cshout);
+ }
+ else {
+ lex[1].word = *v;
+ tellmewhat(lex);
+ }
+ }