aboutsummaryrefslogtreecommitdiff
path: root/lua.stx
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-01-31 12:27:11 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-01-31 12:27:11 -0200
commit1143bf92868a9ec47107a302db43a8e5275d8d80 (patch)
tree648f463b6ea6bbc8985fa7681d90630800cdb62c /lua.stx
parentd9ecc135458a8538c00e12db654513662262d300 (diff)
downloadlua-1143bf92868a9ec47107a302db43a8e5275d8d80.tar.gz
lua-1143bf92868a9ec47107a302db43a8e5275d8d80.tar.bz2
lua-1143bf92868a9ec47107a302db43a8e5275d8d80.zip
better check when converting from float to int, to avoid overflow
(on some machines it may result in run-time error)
Diffstat (limited to 'lua.stx')
-rw-r--r--lua.stx8
1 files changed, 4 insertions, 4 deletions
diff --git a/lua.stx b/lua.stx
index 79b94e7f..61939628 100644
--- a/lua.stx
+++ b/lua.stx
@@ -1,6 +1,6 @@
1%{ 1%{
2 2
3char *rcs_luastx = "$Id: lua.stx,v 3.41 1996/11/08 12:49:35 roberto Exp roberto $"; 3char *rcs_luastx = "$Id: lua.stx,v 3.42 1997/01/15 16:11:37 roberto Exp roberto $";
4 4
5#include <stdio.h> 5#include <stdio.h>
6#include <stdlib.h> 6#include <stdlib.h>
@@ -163,9 +163,9 @@ static void add_varbuffer (Long var)
163 163
164static void code_number (float f) 164static void code_number (float f)
165{ 165{
166 Word i = (Word)f; 166 Word i;
167 if (f == (float)i) /* f has an (short) integer value */ 167 if (f >= 0 && f <= (float)MAX_WORD && (float)(i=(Word)f) == f) {
168 { 168 /* f has an (short) integer value */
169 if (i <= 2) code_byte(PUSH0 + i); 169 if (i <= 2) code_byte(PUSH0 + i);
170 else if (i <= 255) 170 else if (i <= 255)
171 { 171 {