From: Markus Armbruster Date: Sat, 19 Mar 2005 17:16:29 +0000 (+0000) Subject: (nstr_parse_val): strtod() recognizes a few strings as numbers that we X-Git-Tag: v4.2.20~8 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=4bb4376a570a4fed47aa3a423a32c4e3225057a8 (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. --- diff --git a/src/lib/subs/nstr.c b/src/lib/subs/nstr.c index e3911e827..a374f3d3f 100644 --- a/src/lib/subs/nstr.c +++ b/src/lib/subs/nstr.c @@ -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;