details (comments + text of error messages)

This commit is contained in:
Roberto Ierusalimschy
2016-01-06 11:43:05 -02:00
parent 1f259be52a
commit 9945253d57

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: loslib.c,v 1.59 2015/07/06 15:16:51 roberto Exp roberto $ ** $Id: loslib.c,v 1.60 2015/11/19 19:16:22 roberto Exp roberto $
** Standard Operating System library ** Standard Operating System library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -210,18 +210,18 @@ static int getboolfield (lua_State *L, const char *key) {
static int getfield (lua_State *L, const char *key, int d, int delta) { static int getfield (lua_State *L, const char *key, int d, int delta) {
int isnum; int isnum;
int t = lua_getfield(L, -1, key); int t = lua_getfield(L, -1, key); /* get field and its type */
lua_Integer res = lua_tointegerx(L, -1, &isnum); lua_Integer res = lua_tointegerx(L, -1, &isnum);
if (!isnum) { /* field is not a number? */ if (!isnum) { /* field is not an integer? */
if (t != LUA_TNIL) /* some other value? */ if (t != LUA_TNIL) /* some other value? */
return luaL_error(L, "field '%s' not an integer", key); return luaL_error(L, "field '%s' is not an integer", key);
else if (d < 0) /* absent field; no default? */ else if (d < 0) /* absent field; no default? */
return luaL_error(L, "field '%s' missing in date table", key); return luaL_error(L, "field '%s' missing in date table", key);
res = d; res = d;
} }
else { else {
if (!(-L_MAXDATEFIELD <= res && res <= L_MAXDATEFIELD)) if (!(-L_MAXDATEFIELD <= res && res <= L_MAXDATEFIELD))
return luaL_error(L, "field '%s' out-of-bounds", key); return luaL_error(L, "field '%s' is out-of-bound", key);
res -= delta; res -= delta;
} }
lua_pop(L, 1); lua_pop(L, 1);