+
+static int isvalid_enum1(const void *p) { return !!*(const char*)p; }
+static void appres_enum1(Tcl_Interp *ip, const void *p) {
+ char buf[2];
+ buf[0]= *(const char*)p;
+ buf[1]= 0;
+ Tcl_AppendResult(ip, buf, (char*)0);
+}
+
+int enum1_lookup_cached_func(Tcl_Interp *ip, Tcl_Obj *o,
+ const char *opts, const char *what) {
+ const char *supplied, *fp;
+
+ if (o->typePtr != &enum1_nearlytype ||
+ o->internalRep.twoPtrValue.ptr1 != opts) {
+
+ supplied= Tcl_GetStringFromObj(o,0); assert(supplied);
+
+ if (!(strlen(supplied) == 1 &&
+ (fp= strchr(opts, supplied[0])))) {
+ report_bad(ip,what,supplied, opts,1, isvalid_enum1,appres_enum1);
+ return -1;
+ }
+
+ objfreeir(o);
+ o->typePtr= &enum1_nearlytype;
+ o->internalRep.twoPtrValue.ptr1= (void*)opts;
+ o->internalRep.twoPtrValue.ptr2= (void*)fp;
+ }
+ return (const char*)o->internalRep.twoPtrValue.ptr2 - opts;
+}