diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-05 13:59:37 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-05 13:59:37 -0300 |
commit | a102221a0b9f5aa9347b9b15943e39e9d631e0ae (patch) | |
tree | bdd1431942fbb7d337c7f2d6452faeb795511ea5 /lauxlib.c | |
parent | 6dd0b6c62bd0016f456676c335308ebdfe6ce05d (diff) | |
download | lua-a102221a0b9f5aa9347b9b15943e39e9d631e0ae.tar.gz lua-a102221a0b9f5aa9347b9b15943e39e9d631e0ae.tar.bz2 lua-a102221a0b9f5aa9347b9b15943e39e9d631e0ae.zip |
better error messages
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.71 2002/05/16 18:39:46 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.72 2002/06/03 20:11:41 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -37,7 +37,13 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { | |||
37 | lua_Debug ar; | 37 | lua_Debug ar; |
38 | lua_getstack(L, 0, &ar); | 38 | lua_getstack(L, 0, &ar); |
39 | lua_getinfo(L, "n", &ar); | 39 | lua_getinfo(L, "n", &ar); |
40 | if (strcmp(ar.namewhat, "method") == 0) narg--; /* do not count `self' */ | 40 | if (strcmp(ar.namewhat, "method") == 0) { |
41 | narg--; /* do not count `self' */ | ||
42 | if (narg == 0) /* error is in the self argument itself? */ | ||
43 | return luaL_verror(L, | ||
44 | "calling %s on bad self (perhaps using `:' instead of `.')", | ||
45 | ar.name); | ||
46 | } | ||
41 | if (ar.name == NULL) | 47 | if (ar.name == NULL) |
42 | ar.name = "?"; | 48 | ar.name = "?"; |
43 | return luaL_verror(L, "bad argument #%d to `%s' (%s)", | 49 | return luaL_verror(L, "bad argument #%d to `%s' (%s)", |
@@ -314,6 +320,7 @@ typedef struct LoadF { | |||
314 | 320 | ||
315 | static const char *getF (void *ud, size_t *size) { | 321 | static const char *getF (void *ud, size_t *size) { |
316 | LoadF *lf = (LoadF *)ud; | 322 | LoadF *lf = (LoadF *)ud; |
323 | if (feof(lf->f)) return NULL; | ||
317 | *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f); | 324 | *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f); |
318 | return (*size > 0) ? lf->buff : NULL; | 325 | return (*size > 0) ? lf->buff : NULL; |
319 | } | 326 | } |