Annotation of coherent/b/lib/libc/gen/path.c, revision 1.1

1.1     ! root        1: #include <path.h>
        !             2: #define NULL   ((char *)0)
        !             3: char *path(p, f, m) char *p, *f; int m;
        !             4: {
        !             5:        static char pathname[MAXPATH];
        !             6:        register char *p1, *p2, *p3;
        !             7:        register int c, d;
        !             8: 
        !             9:        if ((p1 = p) == NULL)
        !            10:                return NULL;
        !            11:        do {
        !            12:                p2 = pathname;
        !            13:                while ((c = *p1++) != 0 && c != LISTSEP)
        !            14:                        if (p2 < pathname+MAXPATH)
        !            15:                                *p2++ = c;
        !            16:                if (p2 > pathname && p2[-1] != PATHSEP)
        !            17:                        if (p2 < pathname+MAXPATH)
        !            18:                                *p2++ = PATHSEP;
        !            19:                if ((p3 = f) == NULL)
        !            20:                        break;
        !            21:                while ((d = *p3++) != 0)
        !            22:                        if (p2 < pathname+MAXPATH)
        !            23:                                *p2++ = d;
        !            24:                if (p2 < pathname+MAXPATH) {
        !            25:                        *p2 = 0;
        !            26:                        if (access(pathname, m) >= 0)
        !            27:                                return pathname;
        !            28:                }
        !            29:        } while (c != 0);
        !            30:        return NULL;
        !            31: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.