+ *fname++ = pathbuf; /* tokenize path into vector of names */
+ while (*++p)
+ if (*p == ' ' || *p == ':') {
+ *p = '\0';
+ while (*++p)
+ if (*p != ' ' && *p != ':')
+ break;
+ if (*p == '\0')
+ break;
+ *fname++ = p;
+ if (fname >= pathvec + PVECSIZ) {
+ fname--;
+ break;
+ }
+ }
+ *fname = (char *) 0; /* mark end of vector */
+ if (cp && *cp && *cp != '/') {
+ tbuf = cp;
+ c = tnamatch(name);
+ tbuf = bp;
+ if (c) {
+ strcpy(bp,cp);
+ return (tnchktc());
+ }
+ }
+ return (tfindent(bp, name)); /* find terminal entry in path */
+}
+
+/*
+ * tfindent - reads through the list of files in pathvec as if they were one
+ * continuous file searching for terminal entries along the way. It will
+ * participate in indirect recursion if the call to tnchktc() finds a tc=
+ * field, which is only searched for in the current file and files ocurring
+ * after it in pathvec. The usable part of this vector is kept in the global
+ * variable pvec. Terminal entries may not be broken across files. Parse is
+ * very rudimentary; we just notice escaped newlines.
+ */
+tfindent(bp, name)
+ char *bp, *name;
+{
+ register char *cp;
+ register int c;
+ register int i, cnt;
+ char ibuf[BUFSIZ];
+ int opencnt = 0;
+ int tf;
+
+ tbuf = bp;
+nextfile:
+ i = cnt = 0;
+ while (*pvec && (tf = open(*pvec, 0)) < 0)
+ pvec++;
+ if (!*pvec)
+ return (opencnt ? 0 : -1);
+ opencnt++;