(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:
parent
db0773145d
commit
4bb4376a57
1 changed files with 12 additions and 3 deletions
|
@ -269,6 +269,16 @@ nstr_parse_val(char *str, struct valstr *val)
|
|||
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 */
|
||||
l = strtol(str, &tail, 0);
|
||||
d = strtod(str, &tail2);
|
||||
|
@ -285,9 +295,8 @@ nstr_parse_val(char *str, struct valstr *val)
|
|||
return tail;
|
||||
}
|
||||
|
||||
/* identifier */
|
||||
for (tail = str; isalnum(*tail) || *tail == '_'; ++tail) ;
|
||||
if (tail == str) ++tail;
|
||||
/* funny character, interpret as identifier */
|
||||
tail = str+1;
|
||||
val->val_type = NSC_NOTYPE;
|
||||
val->val_cat = NSC_ID;
|
||||
val->val_as.str.base = str;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue