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
1 changed files with 5 additions and 5 deletions

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
** 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) {
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);
if (!isnum) { /* field is not a number? */
if (!isnum) { /* field is not an integer? */
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? */
return luaL_error(L, "field '%s' missing in date table", key);
res = d;
}
else {
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;
}
lua_pop(L, 1);