(xunsymbol): Fix design flaw: negative symbol values were interpreted

as failure.
This commit is contained in:
Markus Armbruster 2005-12-03 13:38:52 +00:00
parent b7eb39ebef
commit 739f346584

View file

@ -198,9 +198,10 @@ freeflds(struct value values[])
} }
static int static int
xunsymbol(struct castr *ca, char *buf) xunsymbol(struct castr *ca, struct value *vp)
{ {
struct symbol *symbol = (struct symbol *)empfile[ca->ca_table].cache; struct symbol *symtab = (struct symbol *)empfile[ca->ca_table].cache;
char *buf = vp->v_field.v_string;
int i; int i;
int value = 0; int value = 0;
char *token; char *token;
@ -214,18 +215,21 @@ xunsymbol(struct castr *ca, char *buf)
return gripe("Empty symbol value for field %s", ca->ca_name); return gripe("Empty symbol value for field %s", ca->ca_name);
while (token) { while (token) {
if ((i = stmtch(token, symbol, offsetof(struct symbol, name), if ((i = stmtch(token, symtab, offsetof(struct symbol, name),
sizeof(struct symbol))) != M_NOTFOUND) { sizeof(struct symbol))) != M_NOTFOUND) {
if (!(ca->ca_flags & NSC_BITS)) if (!(ca->ca_flags & NSC_BITS))
return(symbol[i].value); return(symtab[i].value);
value |= symbol[i].value; value |= symtab[i].value;
} }
else else
return gripe("Symbol %s was not found for field %s", token, return gripe("Symbol %s was not found for field %s", token,
ca->ca_name); ca->ca_name);
token = strtok(NULL, "|"); token = strtok(NULL, "|");
} }
return(value);
vp->v_type = VAL_DOUBLE;
vp->v_field.v_double = value;
return 0;
} }
static int static int
@ -282,13 +286,9 @@ xuloadrow(int type, int row, struct value values[])
return(gripe("Found symbol string %s, but column %s " return(gripe("Found symbol string %s, but column %s "
"is not symbol or symbol sets", "is not symbol or symbol sets",
values[j].v_field.v_string, ca[i].ca_name)); values[j].v_field.v_string, ca[i].ca_name));
values[j].v_field.v_double = if (xunsymbol(&ca[i], &values[j]) < 0)
(double)xunsymbol(&ca[i], values[j].v_field.v_string);
if (values[j].v_field.v_double < 0.0)
return -1; return -1;
/* /* fall through */
* fall through
*/
case VAL_DOUBLE: case VAL_DOUBLE:
switch (ca[i].ca_type) { switch (ca[i].ca_type) {
case NSC_INT: case NSC_INT: