2 * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
7 * Copyright (c) 1988 Regents of the University of California.
10 * Redistribution and use in source and binary forms are permitted
11 * provided that: (1) source distributions retain this entire copyright
12 * notice and comment, and (2) distributions including binaries display
13 * the following acknowledgement: ``This product includes software
14 * developed by the University of California, Berkeley and its contributors''
15 * in the documentation or other materials provided with the distribution
16 * and in all advertising materials mentioning features or use of this
17 * software. Neither the name of the University nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25 #pragma ident "%Z%%M% %I% %E% SMI"
34 * Purpose: the same as strtok ... just different. does not deal with
35 * multiple tokens in row.
38 * s (input) string to scan
39 * delim (input) list of delimiters
40 * <return value> string or null on error.
56 register const char *delim
;
58 register const char *spanp
;
64 if (s
== NULL
&& (s
= last
) == NULL
)
68 * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
73 for (spanp
= delim
; (sc
= *spanp
++) != 0;) {
78 if (c
== 0) { /* no non-delimiter characters */
88 * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
89 * Note that delim must have one NUL; we stop if we see that, too.
95 if ((sc
= *spanp
++) == c
) {