cast_u2s/cast_s2u renamed l_castS2U/l_castU2S to be configurable from

outside (mostly for testing)
This commit is contained in:
Roberto Ierusalimschy
2014-04-15 13:32:49 -03:00
parent 8f961da3db
commit 037a70dfea
6 changed files with 23 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lobject.c,v 2.78 2014/04/11 19:52:26 roberto Exp roberto $
** $Id: lobject.c,v 2.79 2014/04/15 14:28:20 roberto Exp roberto $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
@@ -85,7 +85,7 @@ static lua_Integer intarith (lua_State *L, int op, lua_Integer v1,
case LUA_OPSHL: return luaV_shiftl(v1, v2);
case LUA_OPSHR: return luaV_shiftl(v1, -v2);
case LUA_OPUNM: return intop(-, 0, v1);
case LUA_OPBNOT: return intop(^, ~cast_s2u(0), v1);
case LUA_OPBNOT: return intop(^, ~l_castS2U(0), v1);
default: lua_assert(0); return 0;
}
}
@@ -291,7 +291,7 @@ int luaO_str2int (const char *s, size_t len, lua_Integer *result) {
while (lisspace(cast_uchar(*s))) s++; /* skip trailing spaces */
if (empty || s != ends) return 0; /* something wrong in the numeral */
else {
*result = cast_u2s((neg) ? 0u - a : a);
*result = l_castU2S((neg) ? 0u - a : a);
return 1;
}
}