142080Sbostic/*- 2*61222Sbostic * Copyright (c) 1990, 1993 3*61222Sbostic * The Regents of the University of California. All rights reserved. 442080Sbostic * 542080Sbostic * %sccs.include.redist.c% 642080Sbostic */ 742080Sbostic 842080Sbostic#if defined(LIBC_SCCS) && !defined(lint) 9*61222Sbostic .asciz "@(#)strcspn.s 8.1 (Berkeley) 06/04/93" 1042080Sbostic#endif /* LIBC_SCCS and not lint */ 1142080Sbostic 1242080Sbostic/* 1342080Sbostic * Span the complement of string s2 (skip characters that are not in s2). 1442080Sbostic * Return the number of characters in s1 that were skipped. 1542080Sbostic * 1642080Sbostic * size_t 1742080Sbostic * strcspn(s1, s2) 1842080Sbostic * const char *s1, *s2; 1942080Sbostic */ 2042080Sbostic#include "DEFS.h" 2142080Sbostic 2242080SbosticENTRY(strcspn, 0) 2342080Sbostic subl2 $32,sp /* make 256 bit table */ 2442080Sbostic movc5 $0,(sp),$0,$32,(sp) 2542080Sbostic movq 4(ap),r1 /* r1 = s1, r2 = s2 */ 2642080Sbostic 2742080Sbostic /* turn on bit for each character in s2, including '\0' */ 2842080Sbostic1: 2942080Sbostic movzbl (r2)+,r0 3042080Sbostic bbss r0,(sp),1b 3142080Sbostic bneq 1b 3242080Sbostic movl r1,r0 /* r0 = s (current pos in s1) */ 3342080Sbostic 3442080Sbostic /* look for a character that is in s2 */ 3542080Sbostic2: 3642080Sbostic movzbl (r0)+,r2 /* c = *s++ */ 3742080Sbostic bbc r2,(sp),2b /* loop until c is in table */ 3842080Sbostic decl r0 /* s-- */ 3942080Sbostic subl2 r1,r0 /* r0 = s - s1 = count */ 4042080Sbostic ret 41