Annotation of researchv10no/cmd/prefer/libux3/strtok.c, revision 1.1.1.1

1.1       root        1: /*LINTLIBRARY*/
                      2: /*
                      3:  * uses strpbrk and strspn to break string into tokens on
                      4:  * sequentially subsequent calls.  returns NULL at end.
                      5:  * `subsequent' calls are calls with first argument NULL.
                      6:  */
                      7: 
                      8: #define        NULL    (char *) 0
                      9: 
                     10: char *
                     11: strtok(string, sepset)
                     12: char   *string, *sepset;
                     13: {
                     14:        int     strspn();
                     15:        char    *strpbrk();
                     16:        register char   *p, *q, *r;
                     17:        static  char    *savept;
                     18: 
                     19:        if(string == NULL)
                     20:                p = savept;
                     21:        else
                     22:                p = string;
                     23:        if(p == 0)
                     24:                return(NULL);
                     25:        q = p + strspn(p, sepset);
                     26:        if(*q == '\0')
                     27:                return(NULL);
                     28:        if((r = strpbrk(q, sepset)) == NULL)
                     29:                savept = 0;
                     30:        else {
                     31:                *r = '\0';
                     32:                p = r + strspn(r, sepset);
                     33:                savept = (p > r)? ++p: ++r;
                     34:        }
                     35:        return(q);
                     36: }

unix.superglobalmegacorp.com

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