/*
* Search table TYPE for an element matching NAME, return its index.
+ * Accepts EF_BAD, but of course never finds anything then.
* Return M_NOTFOUND if there are no matches, M_NOTUNIQUE if there are
* several.
*/
ef_elt_byname(int type, char *name)
{
switch (type) {
+ case EF_BAD:
+ return M_NOTFOUND;
case EF_NATION:
return cnumb(name);
case EF_SECTOR_CHR:
* CA describes the field from which the value was fetched.
*/
static char *
-xdprval_sym(struct xdstr *xd, struct valstr *val, struct castr *ca, char *sep)
+xdprval_sym(struct xdstr *xd, struct valstr *val, struct castr *ca,
+ char *sep)
{
unsigned long bit;
- struct castr *ca_sym = ef_cadef(ca->ca_table);
if (CANT_HAPPEN(val->val_cat != NSC_VAL)) {
xd->pr("%snil", sep);
}
if (!xd->human || val->val_type != NSC_LONG
- || ca->ca_table == EF_BAD || ca_sym != symbol_ca)
+ || ca->ca_table == EF_BAD || ef_cadef(ca->ca_table) != symbol_ca)
return xdprval_nosym(xd, val, sep);
if (ca->ca_flags & NSC_BITS) {
{
int type = ca->ca_table;
- if (ef_cadef(type) == symbol_ca)
+ if (type != EF_BAD && ef_cadef(type) == symbol_ca)
/* symbol table, value is in the table */
return ((struct symbol *)ef_ptr(type, i))->value;
/* value is the table index */