diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-02-14 20:23:43 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-02-14 20:23:43 -0200 |
commit | 2c1eb62a0815cd3946902e011747c3724e45b3e8 (patch) | |
tree | 0c6eea4293016ef88434e0b5ed2aeefc2f236e12 | |
parent | 63e2d9212348bf75e5b24630f97213762e4f9bc4 (diff) | |
download | lua-2c1eb62a0815cd3946902e011747c3724e45b3e8.tar.gz lua-2c1eb62a0815cd3946902e011747c3724e45b3e8.tar.bz2 lua-2c1eb62a0815cd3946902e011747c3724e45b3e8.zip |
get error messages from luaL_errstr
-rw-r--r-- | lua.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.74 2001/12/10 22:09:51 lhf Exp $ | 2 | ** $Id: lua.c,v 1.76 2002/02/14 21:47:50 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -12,6 +12,7 @@ | |||
12 | 12 | ||
13 | #include "lua.h" | 13 | #include "lua.h" |
14 | 14 | ||
15 | #include "lauxlib.h" | ||
15 | #include "luadebug.h" | 16 | #include "luadebug.h" |
16 | #include "lualib.h" | 17 | #include "lualib.h" |
17 | 18 | ||
@@ -68,10 +69,8 @@ static void laction (int i) { | |||
68 | 69 | ||
69 | /* Lua gives no message in such cases, so we provide one */ | 70 | /* Lua gives no message in such cases, so we provide one */ |
70 | static void report (int result) { | 71 | static void report (int result) { |
71 | if (result == LUA_ERRMEM) | 72 | if (result == LUA_ERRMEM || result == LUA_ERRERR) |
72 | fprintf(stderr, LUA_PROGNAME "memory allocation error\n"); | 73 | fprintf(stderr, "%s%s\n", LUA_PROGNAME, luaL_errstr(result)); |
73 | else if (result == LUA_ERRERR) | ||
74 | fprintf(stderr, LUA_PROGNAME "error in error message\n"); | ||
75 | } | 74 | } |
76 | 75 | ||
77 | 76 | ||
@@ -143,7 +142,7 @@ static int file_input (const char *name) { | |||
143 | int result = ldo(lua_dofile, name, 1); | 142 | int result = ldo(lua_dofile, name, 1); |
144 | if (result) { | 143 | if (result) { |
145 | if (result == LUA_ERRFILE) { | 144 | if (result == LUA_ERRFILE) { |
146 | fprintf(stderr, LUA_PROGNAME "cannot execute file "); | 145 | fprintf(stderr, "%s%s\n", LUA_PROGNAME, luaL_errstr(result)); |
147 | perror(name); | 146 | perror(name); |
148 | } | 147 | } |
149 | return EXIT_FAILURE; | 148 | return EXIT_FAILURE; |