Annotation of 43BSD/lib/libc/compat-sys5/strtok.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  */
        !             6: 
        !             7: /*
        !             8:  * Sys5 compat routine
        !             9:  */
        !            10: 
        !            11: #if defined(LIBC_SCCS) && !defined(lint)
        !            12: static char sccsid[] = "@(#)strtok.c   5.2 (Berkeley) 86/03/09";
        !            13: #endif
        !            14: 
        !            15: char *
        !            16: strtok(s, sep)
        !            17:        register char *s, *sep;
        !            18: {
        !            19:        register char *p;
        !            20:        register c;
        !            21:        static char *lasts;
        !            22: 
        !            23:        if (s == 0)
        !            24:                s = lasts;
        !            25:        if (s == 0)
        !            26:                return (0);
        !            27: 
        !            28:        while (c = *s) {
        !            29:                if (!index(sep, c))
        !            30:                        break;
        !            31:                s++;
        !            32:        }
        !            33: 
        !            34:        if (c == '\0') {
        !            35:                lasts = 0;
        !            36:                return (0);
        !            37:        }
        !            38: 
        !            39:        for (p = s; c = *++p; )
        !            40:                if (index(sep, c))
        !            41:                        break;
        !            42: 
        !            43:        if (c == '\0')
        !            44:                lasts = 0;
        !            45:        else {
        !            46:                *p++ = '\0';
        !            47:                lasts = p;
        !            48:        }
        !            49:        return (s);
        !            50: }

unix.superglobalmegacorp.com

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