From 0bbd96bd5f973f716a93a704e04cf1c78145795f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 13 Apr 1999 16:28:49 -0300 Subject: details. --- lobject.c | 18 +++++++++--------- lvm.c | 9 ++++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lobject.c b/lobject.c index 984d6f12..840e367f 100644 --- a/lobject.c +++ b/lobject.c @@ -1,5 +1,5 @@ /* -** $Id: lobject.c,v 1.17 1999/02/12 19:23:02 roberto Exp roberto $ +** $Id: lobject.c,v 1.18 1999/02/26 15:48:30 roberto Exp roberto $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ @@ -93,25 +93,25 @@ static double expten (unsigned int e) { double luaO_str2d (char *s) { /* LUA_NUMBER */ double a = 0.0; int point = 0; - if (!isdigit((unsigned char)*s) && !isdigit((unsigned char)*(s+1))) - return -1; /* no digit before or after decimal point */ while (isdigit((unsigned char)*s)) { a = 10.0*a + (*(s++)-'0'); } - if (*s == '.') s++; - while (isdigit((unsigned char)*s)) { - a = 10.0*a + (*(s++)-'0'); - point++; + if (*s == '.') { + s++; + while (isdigit((unsigned char)*s)) { + a = 10.0*a + (*(s++)-'0'); + point++; + } } if (toupper((unsigned char)*s) == 'E') { int e = 0; int sig = 1; s++; - if (*s == '+') s++; - else if (*s == '-') { + if (*s == '-') { s++; sig = -1; } + else if (*s == '+') s++; if (!isdigit((unsigned char)*s)) return -1; /* no digit in the exponent? */ do { e = 10*e + (*(s++)-'0'); diff --git a/lvm.c b/lvm.c index 814eba82..db7e3a56 100644 --- a/lvm.c +++ b/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 1.53 1999/03/05 21:16:07 roberto Exp roberto $ +** $Id: lvm.c,v 1.54 1999/03/10 14:09:45 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -57,11 +57,14 @@ int luaV_tonumber (TObject *obj) { /* LUA_NUMBER */ char *e = svalue(obj); int sig = 1; while (isspace((unsigned char)*e)) e++; - if (*e == '+') e++; - else if (*e == '-') { + if (*e == '-') { e++; sig = -1; } + else if (*e == '+') e++; + /* no digit before or after decimal point? */ + if (!isdigit((unsigned char)*e) && !isdigit((unsigned char)*(e+1))) + return 2; t = luaO_str2d(e); if (t<0) return 2; nvalue(obj) = (real)t*sig; -- cgit v1.2.3-55-g6feb