|
|
1.1 ! root 1: /*- ! 2: * Copyright (c) 1990 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that: (1) source distributions retain this entire copyright ! 7: * notice and comment, and (2) distributions including binaries display ! 8: * the following acknowledgement: ``This product includes software ! 9: * developed by the University of California, Berkeley and its contributors'' ! 10: * in the documentation or other materials provided with the distribution ! 11: * and in all advertising materials mentioning features or use of this ! 12: * software. Neither the name of the University nor the names of its ! 13: * contributors may be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #if defined(LIBC_SCCS) && !defined(lint) ! 21: .asciz "@(#)strsep.s 5.1 (Berkeley) 5/15/90" ! 22: #endif /* LIBC_SCCS and not lint */ ! 23: ! 24: /* ! 25: * Get next word from string *stringp, where words are ! 26: * strings separated by characters from delim. ! 27: * ! 28: * Writes NULs into the string at *stringp to end tokens. ! 29: * On return, *stringp points past the last NUL written (if there might ! 30: * be further tokens), or is NULL (if there are definitely no more tokens). ! 31: * ! 32: * If *stringp is NULL, strtoken returns NULL. ! 33: * ! 34: * char * ! 35: * strtoken(stringp, delim) ! 36: * register char **stringp; ! 37: * register char const *delim; ! 38: */ ! 39: #include "DEFS.h" ! 40: ! 41: ENTRY(strsep, 0) ! 42: tstl *4(ap) /* if (*stringp == NULL) */ ! 43: bneq 0f ! 44: clrl r0 # return (NULL); ! 45: ret ! 46: ! 47: 0: ! 48: subl2 $32,sp /* make room for 256 bit table */ ! 49: movc5 $0,(sp),$0,$32,(sp) ! 50: movq 4(ap),r1 /* r1 = stringp, r2 = delim */ ! 51: ! 52: /* turn on bit for each character in s2, including '\0' */ ! 53: 1: ! 54: movzbl (r2)+,r0 ! 55: bbss r0,(sp),1b ! 56: bneq 1b ! 57: ! 58: movl (r1),r3 /* r3 = s = *stringp */ ! 59: movl r3,r0 /* save return value */ ! 60: ! 61: /* scan for delimiters */ ! 62: 2: ! 63: movzbl (r3)+,r2 /* c = *s++ */ ! 64: bbc r2,(sp),2b /* loop until c is in table */ ! 65: beql 3f ! 66: clrb -1(r3) /* if c!='\0', s[-1] = 0 */ ! 67: movl r3,(r1) /* and *stringp = s */ ! 68: ret ! 69: 3: ! 70: clrl (r1) /* else *stringp = NULL */ ! 71: ret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.