aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lbaselib.c4
-rw-r--r--lobject.c7
-rw-r--r--lvm.c6
3 files changed, 8 insertions, 9 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 30e19ee4..f3964c70 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.278 2013/07/05 14:35:49 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.279 2013/07/05 14:39:15 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -63,7 +63,7 @@ static int b_str2int (const char *s, const char *e, int base, lua_Integer *pn) {
63 s += strspn(s, SPACECHARS); /* skip trailing spaces */ 63 s += strspn(s, SPACECHARS); /* skip trailing spaces */
64 if (s != e) /* invalid trailing characters? */ 64 if (s != e) /* invalid trailing characters? */
65 return 0; 65 return 0;
66 *pn = (neg) ? -(lua_Integer)n : (lua_Integer)n; 66 *pn = (lua_Integer)((neg) ? (0u - n) : n);
67 return 1; 67 return 1;
68} 68}
69 69
diff --git a/lobject.c b/lobject.c
index dcd81a96..92721332 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 2.66 2013/06/04 19:36:42 roberto Exp roberto $ 2** $Id: lobject.c,v 2.67 2013/06/25 18:58:32 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -78,7 +78,7 @@ static lua_Integer intarith (lua_State *L, int op, lua_Integer v1,
78 case LUA_OPMUL:return intop(*, v1, v2); 78 case LUA_OPMUL:return intop(*, v1, v2);
79 case LUA_OPMOD: return luaV_mod(L, v1, v2); 79 case LUA_OPMOD: return luaV_mod(L, v1, v2);
80 case LUA_OPPOW: return luaV_pow(v1, v2); 80 case LUA_OPPOW: return luaV_pow(v1, v2);
81 case LUA_OPUNM: return -v1; 81 case LUA_OPUNM: return intop(-, 0, v1);
82 default: lua_assert(0); return 0; 82 default: lua_assert(0); return 0;
83 } 83 }
84} 84}
@@ -260,8 +260,7 @@ int luaO_str2int (const char *s, size_t len, lua_Integer *result) {
260 while (lisspace(cast_uchar(*s))) s++; /* skip trailing spaces */ 260 while (lisspace(cast_uchar(*s))) s++; /* skip trailing spaces */
261 if (empty || s != ends) return 0; /* something wrong in the numeral */ 261 if (empty || s != ends) return 0; /* something wrong in the numeral */
262 else { 262 else {
263 if (neg) *result = -cast(lua_Integer, a); 263 *result = cast_integer((neg) ? 0u - a : a);
264 else *result = cast(lua_Integer, a);
265 return 1; 264 return 1;
266 } 265 }
267} 266}
diff --git a/lvm.c b/lvm.c
index fc335876..67aa58f8 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.174 2013/06/19 14:27:00 roberto Exp roberto $ 2** $Id: lvm.c,v 2.175 2013/06/20 15:02:49 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*/
@@ -334,7 +334,7 @@ lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y) {
334 if (y == 0) 334 if (y == 0)
335 luaG_runerror(L, "attempt to divide by zero"); 335 luaG_runerror(L, "attempt to divide by zero");
336 else /* -1 */ 336 else /* -1 */
337 return -x; /* avoid overflow with 0x80000... */ 337 return intop(-, 0, x); /* avoid overflow with 0x80000... */
338 } 338 }
339 else { 339 else {
340 lua_Integer d = x / y; /* perform division */ 340 lua_Integer d = x / y; /* perform division */
@@ -699,7 +699,7 @@ void luaV_execute (lua_State *L) {
699 lua_Number nb; 699 lua_Number nb;
700 if (ttisinteger(rb)) { 700 if (ttisinteger(rb)) {
701 lua_Integer ib = ivalue(rb); 701 lua_Integer ib = ivalue(rb);
702 setivalue(ra, -ib); 702 setivalue(ra, intop(-, 0, ib));
703 } 703 }
704 else if (tonumber(rb, &nb)) { 704 else if (tonumber(rb, &nb)) {
705 setnvalue(ra, luai_numunm(L, nb)); 705 setnvalue(ra, luai_numunm(L, nb));