aboutsummaryrefslogtreecommitdiff
path: root/lobject.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-07-10 14:15:12 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-07-10 14:15:12 -0300
commit2f8c51a5529686959c6f6c5a8e899127b16c345d (patch)
tree6fcd69bf68ed7595578db0e196ad29863faf6257 /lobject.c
parentb5f5fcd78251300aee44d958b9ac000fa05e0478 (diff)
downloadlua-2f8c51a5529686959c6f6c5a8e899127b16c345d.tar.gz
lua-2f8c51a5529686959c6f6c5a8e899127b16c345d.tar.bz2
lua-2f8c51a5529686959c6f6c5a8e899127b16c345d.zip
use unsigneds for unary minus, too
Diffstat (limited to 'lobject.c')
-rw-r--r--lobject.c7
1 files changed, 3 insertions, 4 deletions
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}