util  tbl.c at tip

File clib/tbl.c from the latest check-in


/* [ʞ] tbl.c
 *  ~ lexi hale <lexi@hale.su>
 *  ? simple table-scanning function to make
 *    parsing easier */

struct tblrow { tbl_word_type val; const char* str; };

tbl_error_type tblget(size_t stacksz, const struct tblrow* haystack, const char* needle, tbl_word_type* val) {
	for (size_t i = 0; i<stacksz; ++i) {
		if (strcmp(haystack[i].str, needle) == ok) {
			*val = haystack[i].val;
			return tbl_ok;
		}
	}
	return tbl_error;
}