diff options
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 1.53 1999/03/05 21:16:07 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 1.54 1999/03/10 14:09:45 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 | */ |
@@ -57,11 +57,14 @@ int luaV_tonumber (TObject *obj) { /* LUA_NUMBER */ | |||
57 | char *e = svalue(obj); | 57 | char *e = svalue(obj); |
58 | int sig = 1; | 58 | int sig = 1; |
59 | while (isspace((unsigned char)*e)) e++; | 59 | while (isspace((unsigned char)*e)) e++; |
60 | if (*e == '+') e++; | 60 | if (*e == '-') { |
61 | else if (*e == '-') { | ||
62 | e++; | 61 | e++; |
63 | sig = -1; | 62 | sig = -1; |
64 | } | 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; | ||
65 | t = luaO_str2d(e); | 68 | t = luaO_str2d(e); |
66 | if (t<0) return 2; | 69 | if (t<0) return 2; |
67 | nvalue(obj) = (real)t*sig; | 70 | nvalue(obj) = (real)t*sig; |