function "luaL_argerror" prints wrong argument number (from a user's point

of view) when functions have upvalues.
This commit is contained in:
Roberto Ierusalimschy 1998-09-07 15:59:59 -03:00
parent b1450721be
commit ce9609296c
3 changed files with 17 additions and 9 deletions

9
bugs
View File

@ -31,7 +31,7 @@ Tue Jan 27 17:12:36 EDT 1998
** lstring.c / ltable.c
Wed Jan 28 14:48:12 EDT 1998
>> tables can become full of "emptys" slots, and keep growing without limits.
>> tables can become full of "empty" slots, and keep growing without limits.
** lstrlib.c
Mon Mar 9 15:26:09 EST 1998
@ -41,3 +41,10 @@ Mon Mar 9 15:26:09 EST 1998
Mon May 18 19:20:00 EST 1998
>> arguments for "format" 'x', 'X', 'o' and 'u' must be unsigned int.
--- Version 3.1
** liolib.c / lauxlib.c
Mon Sep 7 15:57:02 EST 1998
>> function "luaL_argerror" prints wrong argument number (from a user's point
of view) when functions have upvalues.

View File

@ -1,5 +1,5 @@
/*
** $Id: lauxlib.c,v 1.11 1998/06/18 16:57:03 roberto Exp roberto $
** $Id: lauxlib.c,v 1.12 1998/06/19 16:14:09 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@ -27,10 +27,11 @@ int luaL_findstring (char *name, char *list[]) {
return -1; /* name not found */
}
void luaL_argerror (int numarg, char *extramsg)
{
void luaL_argerror (int numarg, char *extramsg) {
lua_Function f = lua_stackedfunction(0);
char *funcname;
lua_getobjname(lua_stackedfunction(0), &funcname);
lua_getobjname(f, &funcname);
numarg -= lua_nups(f);
if (funcname == NULL)
funcname = "???";
if (extramsg == NULL)

View File

@ -1,5 +1,5 @@
/*
** $Id: liolib.c,v 1.23 1998/08/24 20:14:56 roberto Exp roberto $
** $Id: liolib.c,v 1.24 1998/08/30 20:25:24 roberto Exp roberto $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@ -284,8 +284,8 @@ static void io_seek (void) {
FILE *f = getfile(FIRSTARG-1+1);
int op = luaL_findstring(luaL_opt_string(FIRSTARG-1+2, "cur"), modenames);
long offset = luaL_opt_number(FIRSTARG-1+3, 0);
luaL_arg_check(f, 1, "invalid file handler");
luaL_arg_check(op != -1, 2, "invalid mode");
luaL_arg_check(f, FIRSTARG-1+1, "invalid file handler");
luaL_arg_check(op != -1, FIRSTARG-1+2, "invalid mode");
op = fseek(f, offset, mode[op]);
if (op)
pushresult(0); /* error */
@ -296,7 +296,7 @@ static void io_seek (void) {
static void io_flush (void) {
FILE *f = getfile(FIRSTARG);
luaL_arg_check(f || lua_getparam(FIRSTARG) == LUA_NOOBJECT, 1,
luaL_arg_check(f || lua_getparam(FIRSTARG) == LUA_NOOBJECT, FIRSTARG,
"invalid file handler");
pushresult(fflush(f) == 0);
}