/*
	str_cnt(s, list)

	Count the number of occurrences of letters in list[] in string s[]
*/
#include <ncbi.h>
#include <gishlib.h>

size_t LIBCALL
str_cnt(s, list)
	CharPtr	s;
	CharPtr	list;
{
	/* cmap[] is allocated on the stack, in case of interrupt */
	Byte	cmap[1<<(CHAR_BIT*sizeof(char))];
	register Byte	c;
	register size_t	cnt = 0;
	register BytePtr us = (BytePtr)s, ulist = (BytePtr)list;

	Nlm_MemSet((VoidPtr)cmap, 0, sizeof(cmap));
	while (*ulist != NULLB)
		cmap[*ulist++] = 1;

	ulist = (BytePtr)cmap;

	while ((c = *us++) != NULLB)
		cnt += ulist[c];

	return cnt;
}

