(nstr_exec, nstr_comp_val, nstr_exec_val): Values of type NSTR aren't

implemented and thus cannot occur.  Document this more clearly.

(nstr_comp_val): More logical order.  No functional changes.
This commit is contained in:
Markus Armbruster 2004-05-09 15:44:54 +00:00
parent b845997df3
commit e4d1c38c96

View file

@ -168,7 +168,8 @@ nstr_exec(struct nscstr *np, int ncond, void *ptr)
return 0; return 0;
break; break;
case NSC_STRING: case NSC_STRING:
return 0; /* FIXME */ CANT_HAPPEN("unimplemented OPTYPE"); /* FIXME */
return 0;
default: default:
CANT_HAPPEN("bad OPTYPE"); CANT_HAPPEN("bad OPTYPE");
return 0; return 0;
@ -242,6 +243,11 @@ nstr_comp_val(char *str, struct valstr*val, int type)
return val->val_type == NSC_NOTYPE ? NULL : tail; return val->val_type == NSC_NOTYPE ? NULL : tail;
} }
/* single character type */
id[0] = str[0];
id[1] = 0;
val->val_as_type = typematch(id, type);
/* literals */ /* literals */
l = strtol(str, &tail, 0); l = strtol(str, &tail, 0);
d = strtod(str, &tail2); d = strtod(str, &tail2);
@ -257,12 +263,9 @@ nstr_comp_val(char *str, struct valstr*val, int type)
val->val_as.lng = l; val->val_as.lng = l;
return tail; return tail;
} }
/* FIXME NSC_STRING */ /* FIXME implement NSC_STRING literals */
/* single character type */ CANT_HAPPEN(val->val_type != NSC_NOTYPE);
id[0] = str[0];
id[1] = 0;
val->val_as_type = typematch(id, type);
if (val->val_as_type >= 0) { if (val->val_as_type >= 0) {
val->val_type = NSC_TYPEID; val->val_type = NSC_TYPEID;
val->val_cat = NSC_VAL; val->val_cat = NSC_VAL;
@ -344,7 +347,7 @@ nstr_coerce_val(struct valstr *val, nsc_type to, char *str)
return cond_type_mismatch(str); return cond_type_mismatch(str);
break; break;
case NSC_STRING: case NSC_STRING:
return cond_type_mismatch(str); /* FIXME */ return cond_type_mismatch(str); /* FIXME implement */
case NSC_DOUBLE: case NSC_DOUBLE:
if (from == NSC_LONG) { if (from == NSC_LONG) {
if (val->val_cat == NSC_VAL) if (val->val_cat == NSC_VAL)
@ -454,7 +457,7 @@ nstr_exec_val(struct valstr *val, natid cnum, void *ptr, nsc_type want)
val->val_as.dbl = val->val_as.lng; val->val_as.dbl = val->val_as.lng;
} }
} else if (want == NSC_STRING) } else if (want == NSC_STRING)
; /* FIXME */ CANT_HAPPEN("unimplemented WANT"); /* FIXME */
if (CANT_HAPPEN(valtype != want)) { if (CANT_HAPPEN(valtype != want)) {
valtype = want; valtype = want;
switch (want) { switch (want) {