xref: /original-bsd/usr.bin/pascal/libpc/IN.c (revision 33717ddf)
1ab0b9960Sbostic /*-
2*33717ddfSbostic  * Copyright (c) 1979, 1993
3*33717ddfSbostic  *	The Regents of the University of California.  All rights reserved.
4ab0b9960Sbostic  *
5ab0b9960Sbostic  * %sccs.include.redist.c%
6ab0b9960Sbostic  */
779154f4bSmckusick 
8ab0b9960Sbostic #ifndef lint
9*33717ddfSbostic static char sccsid[] = "@(#)IN.c	8.1 (Berkeley) 06/06/93";
10ab0b9960Sbostic #endif /* not lint */
1179154f4bSmckusick 
1279154f4bSmckusick #include "h00vars.h"
1379154f4bSmckusick 
1449100586Smckusic bool
IN(element,lower,upper,setptr)1579154f4bSmckusick IN(element, lower, upper, setptr)
1679154f4bSmckusick 
1749100586Smckusic 	long	element;	/* element to check */
1849100586Smckusic 	long	lower;		/* lowest element of set */
1949100586Smckusic 	long	upper;		/* upper - lower of set */
2079154f4bSmckusick 	char	setptr[];	/* pointer to set */
2179154f4bSmckusick {
2249100586Smckusic 	register int	indx;
2379154f4bSmckusick 
2479154f4bSmckusick 	if ((indx = element - lower) < 0 || indx > upper)
2579154f4bSmckusick 		return FALSE;
2649100586Smckusic 	if (setptr[indx >> LG2BITSBYTE] & (1 << (indx & MSKBITSBYTE)))
2779154f4bSmckusick 		return TRUE;
2879154f4bSmckusick 	return FALSE;
2979154f4bSmckusick }
30