flag fields are u_int's
[unix-history] / usr / src / lib / libc / vax / string / strsep.s
CommitLineData
cd6c9416
KB
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8#if defined(LIBC_SCCS) && !defined(lint)
9 .asciz "@(#)strsep.s 5.1 (Berkeley) %G%"
10#endif /* LIBC_SCCS and not lint */
11
12/*
13 * Get next word from string *stringp, where words are
14 * strings separated by characters from delim.
15 *
16 * Writes NULs into the string at *stringp to end tokens.
17 * On return, *stringp points past the last NUL written (if there might
18 * be further tokens), or is NULL (if there are definitely no more tokens).
19 *
20 * If *stringp is NULL, strtoken returns NULL.
21 *
22 * char *
23 * strtoken(stringp, delim)
24 * register char **stringp;
25 * register char const *delim;
26 */
27#include "DEFS.h"
28
29ENTRY(strsep, 0)
30 tstl *4(ap) /* if (*stringp == NULL) */
31 bneq 0f
32 clrl r0 # return (NULL);
33 ret
34
350:
36 subl2 $32,sp /* make room for 256 bit table */
37 movc5 $0,(sp),$0,$32,(sp)
38 movq 4(ap),r1 /* r1 = stringp, r2 = delim */
39
40 /* turn on bit for each character in s2, including '\0' */
411:
42 movzbl (r2)+,r0
43 bbss r0,(sp),1b
44 bneq 1b
45
46 movl (r1),r3 /* r3 = s = *stringp */
47 movl r3,r0 /* save return value */
48
49 /* scan for delimiters */
502:
51 movzbl (r3)+,r2 /* c = *s++ */
52 bbc r2,(sp),2b /* loop until c is in table */
53 beql 3f
54 clrb -1(r3) /* if c!='\0', s[-1] = 0 */
55 movl r3,(r1) /* and *stringp = s */
56 ret
573:
58 clrl (r1) /* else *stringp = NULL */
59 ret