FreeBSD/contrib/mdocml/roff.c
/*
 * Look up a roff token by its name.  Returns ROFF_MAX if no macro by
 * the nil-terminated string name could be found.
 */
Look up a roff token by its name.  Returns ROFF_MAX if no macro by
the nil-terminated string name could be found.
Look up a roff token by its name . Returns ROFF_MAX if no macro by the nil - terminated string name could be found .
static enum rofft
roffhash_find(const char *p, size_t s)
{
	int		 buc;
	struct roffmac	*n;
	if (p[0] < ASCII_LO || p[0] > ASCII_HI)
		return ROFF_MAX;
	buc = ROFF_HASH(p);
	if (NULL == (n = hash[buc]))
		return ROFF_MAX;
	for ( ; n; n = n->next)
		if (0 == strncmp(n->name, p, s) && '\0' == n->name[(int)s])
			return (enum rofft)(n - roffs);
	return ROFF_MAX;
}
static enum rofft roffhash_find ( const char * p , size_t s ) { int buc ; struct roffmac * n ; if ( p [ 0 ] < ASCII_LO || p [ 0 ] > ASCII_HI ) return ROFF_MAX ; buc = ROFF_HASH ( p ) ; if ( NULL == ( n = hash [ buc ] ) ) return ROFF_MAX ; for ( ; n ; n = n -> next ) if ( 0 == strncmp ( n -> name , p , s ) && ' \0 ' == n -> name [ ( int ) s ] ) return ( enum rofft ) ( n - roffs ) ; return ROFF_MAX ; }
Look up a roff token by its name.
Look up a roff token by its name .
/*
	 * libroff has an extremely simple hashtable, for the time
	 * being, which simply keys on the first character, which must
	 * be printable, then walks a chain.  It works well enough until
	 * optimised.
	 */