'numisinteger' (for table keys) replaced by 'luaV_tointeger' (old

'tointeger_aux'), which can do the same job.
This commit is contained in:
Roberto Ierusalimschy
2015-02-20 12:27:53 -02:00
parent 397ce11996
commit 81245b1ad5
3 changed files with 21 additions and 41 deletions

24
lvm.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 2.233 2015/01/16 16:54:37 roberto Exp roberto $
** $Id: lvm.c,v 2.234 2015/02/05 17:15:33 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -31,16 +31,6 @@
#include "lvm.h"
/*
** You can define LUA_FLOORN2I if you want to convert floats to integers
** by flooring them (instead of raising an error if they are not
** integral values)
*/
#if !defined(LUA_FLOORN2I)
#define LUA_FLOORN2I 0
#endif
/* limit for table tag-method chains (to avoid loops) */
#define MAXTAGLOOP 2000
@@ -89,7 +79,7 @@ int luaV_tonumber_ (const TValue *obj, lua_Number *n) {
** mode == 1: takes the floor of the number
** mode == 2: takes the ceil of the number
*/
static int tointeger_aux (const TValue *obj, lua_Integer *p, int mode) {
int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode) {
TValue v;
again:
if (ttisfloat(obj)) {
@@ -115,14 +105,6 @@ static int tointeger_aux (const TValue *obj, lua_Integer *p, int mode) {
}
/*
** try to convert a value to an integer
*/
int luaV_tointeger_ (const TValue *obj, lua_Integer *p) {
return tointeger_aux(obj, p, LUA_FLOORN2I);
}
/*
** Try to convert a 'for' limit to an integer, preserving the
** semantics of the loop.
@@ -141,7 +123,7 @@ int luaV_tointeger_ (const TValue *obj, lua_Integer *p) {
static int forlimit (const TValue *obj, lua_Integer *p, lua_Integer step,
int *stopnow) {
*stopnow = 0; /* usually, let loops run */
if (!tointeger_aux(obj, p, (step < 0 ? 2 : 1))) { /* not fit in integer? */
if (!luaV_tointeger(obj, p, (step < 0 ? 2 : 1))) { /* not fit in integer? */
lua_Number n; /* try to convert to float */
if (!tonumber(obj, &n)) /* cannot convert to float? */
return 0; /* not a number */