(nstr_parse_val): strtod() recognizes a few strings as numbers that we

want to recognize as identifiers, notably "inf".  Recognize
identifiers starting with letters before numbers.
This commit is contained in:
Markus Armbruster 2005-03-19 17:16:29 +00:00
parent db0773145d
commit 4bb4376a57

View file

@ -269,6 +269,16 @@ nstr_parse_val(char *str, struct valstr *val)
return tail; return tail;
} }
/* identifier */
if (isalpha(str[0])) {
for (tail = str+1; isalnum(*tail) || *tail == '_'; ++tail) ;
val->val_type = NSC_NOTYPE;
val->val_cat = NSC_ID;
val->val_as.str.base = str;
val->val_as.str.maxsz = tail - str;
return tail;
}
/* number */ /* number */
l = strtol(str, &tail, 0); l = strtol(str, &tail, 0);
d = strtod(str, &tail2); d = strtod(str, &tail2);
@ -285,9 +295,8 @@ nstr_parse_val(char *str, struct valstr *val)
return tail; return tail;
} }
/* identifier */ /* funny character, interpret as identifier */
for (tail = str; isalnum(*tail) || *tail == '_'; ++tail) ; tail = str+1;
if (tail == str) ++tail;
val->val_type = NSC_NOTYPE; val->val_type = NSC_NOTYPE;
val->val_cat = NSC_ID; val->val_cat = NSC_ID;
val->val_as.str.base = str; val->val_as.str.base = str;