diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-09-06 17:34:18 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-09-06 17:34:18 -0300 |
commit | 2e13cd77ab3b3719ef139e4786328be813fb10e0 (patch) | |
tree | 17717c1015f20dff2ac62cfd2a082c4aba5ab206 /lvm.c | |
parent | ff9c0da7839543478d62306dd208f11caab130c1 (diff) | |
download | lua-2e13cd77ab3b3719ef139e4786328be813fb10e0.tar.gz lua-2e13cd77ab3b3719ef139e4786328be813fb10e0.tar.bz2 lua-2e13cd77ab3b3719ef139e4786328be813fb10e0.zip |
new interface for `luaO_strtod', which now checks signal, too.
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 17 |
1 files changed, 2 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.59 1999/08/10 12:55:47 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.60 1999/08/16 20:52:00 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -53,21 +53,8 @@ int luaV_tonumber (TObject *obj) { /* LUA_NUMBER */ | |||
53 | if (ttype(obj) != LUA_T_STRING) | 53 | if (ttype(obj) != LUA_T_STRING) |
54 | return 1; | 54 | return 1; |
55 | else { | 55 | else { |
56 | real t; | 56 | if (!luaO_str2d(svalue(obj), &nvalue(obj))) |
57 | char *e = svalue(obj); | ||
58 | int sig = 1; | ||
59 | while (isspace((unsigned char)*e)) e++; | ||
60 | if (*e == '-') { | ||
61 | e++; | ||
62 | sig = -1; | ||
63 | } | ||
64 | else if (*e == '+') e++; | ||
65 | /* no digit before or after decimal point? */ | ||
66 | if (!isdigit((unsigned char)*e) && !isdigit((unsigned char)*(e+1))) | ||
67 | return 2; | 57 | return 2; |
68 | t = (real)luaO_str2d(e); | ||
69 | if (t<0) return 2; | ||
70 | nvalue(obj) = t*sig; | ||
71 | ttype(obj) = LUA_T_NUMBER; | 58 | ttype(obj) = LUA_T_NUMBER; |
72 | return 0; | 59 | return 0; |
73 | } | 60 | } |