aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lex.c4
-rw-r--r--opcode.c27
2 files changed, 15 insertions, 16 deletions
diff --git a/lex.c b/lex.c
index 81cbe527..59588d19 100644
--- a/lex.c
+++ b/lex.c
@@ -1,4 +1,4 @@
1char *rcs_lex = "$Id: lex.c,v 3.7 1997/07/29 13:33:15 roberto Exp roberto $"; 1char *rcs_lex = "$Id: lex.c,v 3.8 1997/07/30 22:00:50 roberto Exp roberto $";
2 2
3 3
4#include <ctype.h> 4#include <ctype.h>
@@ -432,7 +432,7 @@ int luaY_lex (void)
432 ea*=ea; 432 ea*=ea;
433 } 433 }
434 } 434 }
435 luaY_lval.vFloat = a; 435 luaY_lval.vReal = a;
436 save(0); 436 save(0);
437 return NUMBER; 437 return NUMBER;
438 } 438 }
diff --git a/opcode.c b/opcode.c
index 505e6c45..a5ade2cf 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_opcode="$Id: opcode.c,v 4.19 1997/07/29 21:11:10 roberto Exp roberto $"; 6char *rcs_opcode="$Id: opcode.c,v 4.20 1997/07/30 22:00:50 roberto Exp roberto $";
7 7
8#include <setjmp.h> 8#include <setjmp.h>
9#include <stdio.h> 9#include <stdio.h>
@@ -141,18 +141,17 @@ static char *lua_strconc (char *l, char *r)
141*/ 141*/
142static int lua_tonumber (TObject *obj) 142static int lua_tonumber (TObject *obj)
143{ 143{
144 float t; 144 double t;
145 char c; 145 char c;
146 if (ttype(obj) != LUA_T_STRING) 146 if (ttype(obj) != LUA_T_STRING)
147 return 1; 147 return 1;
148 else if (sscanf(svalue(obj), "%f %c",&t, &c) == 1) 148 else if (sscanf(svalue(obj), "%lf %c",&t, &c) == 1) {
149 { 149 nvalue(obj) = (real)t;
150 nvalue(obj) = t; 150 ttype(obj) = LUA_T_NUMBER;
151 ttype(obj) = LUA_T_NUMBER; 151 return 0;
152 return 0; 152 }
153 } 153 else
154 else 154 return 2;
155 return 2;
156} 155}
157 156
158 157
@@ -171,7 +170,7 @@ static int lua_tostring (TObject *obj)
171 if ((real)(-MAX_INT) <= f && f <= (real)MAX_INT && (real)(i=(int)f) == f) 170 if ((real)(-MAX_INT) <= f && f <= (real)MAX_INT && (real)(i=(int)f) == f)
172 sprintf (s, "%d", i); 171 sprintf (s, "%d", i);
173 else 172 else
174 sprintf (s, "%g", nvalue(obj)); 173 sprintf (s, "%g", (double)nvalue(obj));
175 tsvalue(obj) = luaI_createstring(s); 174 tsvalue(obj) = luaI_createstring(s);
176 ttype(obj) = LUA_T_STRING; 175 ttype(obj) = LUA_T_STRING;
177 return 0; 176 return 0;