luaL_dofile' and luaL_dostring' are deprecated

This commit is contained in:
Roberto Ierusalimschy 2004-05-31 16:27:14 -03:00
parent 616438fe9a
commit 1e0aaf2156
3 changed files with 9 additions and 63 deletions

View File

@ -1,5 +1,5 @@
/*
** $Id: lauxlib.c,v 1.111 2004/04/30 20:13:38 roberto Exp roberto $
** $Id: lauxlib.c,v 1.112 2004/05/10 17:50:51 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@ -555,6 +555,7 @@ LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
return lua_load(L, getS, &ls, name);
}
/* }====================================================== */
@ -573,51 +574,3 @@ LUALIB_API lua_State *luaL_newstate (void) {
return lua_newstate(l_alloc, NULL);
}
/*
** {======================================================
** compatibility code
** =======================================================
*/
static void callalert (lua_State *L, int status) {
if (status != 0) {
lua_getglobal(L, "_ALERT");
if (lua_isfunction(L, -1)) {
lua_insert(L, -2);
lua_call(L, 1, 0);
}
else { /* no _ALERT function; print it on stderr */
fprintf(stderr, "%s\n", lua_tostring(L, -2));
lua_pop(L, 2); /* remove error message and _ALERT */
}
}
}
static int aux_do (lua_State *L, int status) {
if (status == 0) { /* parse OK? */
status = lua_pcall(L, 0, LUA_MULTRET, 0); /* call main */
}
callalert(L, status);
return status;
}
LUALIB_API int lua_dofile (lua_State *L, const char *filename) {
return aux_do(L, luaL_loadfile(L, filename));
}
LUALIB_API int lua_dobuffer (lua_State *L, const char *buff, size_t size,
const char *name) {
return aux_do(L, luaL_loadbuffer(L, buff, size, name));
}
LUALIB_API int lua_dostring (lua_State *L, const char *str) {
return lua_dobuffer(L, str, strlen(str), str);
}
/* }====================================================== */

View File

@ -1,5 +1,5 @@
/*
** $Id: lauxlib.h,v 1.63 2004/03/13 13:32:09 roberto Exp roberto $
** $Id: lauxlib.h,v 1.64 2004/05/03 12:28:43 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@ -113,17 +113,6 @@ LUALIB_API void luaL_pushresult (luaL_Buffer *B);
/* }====================================================== */
/*
** Compatibility macros and functions
*/
LUALIB_API int lua_dofile (lua_State *L, const char *filename);
LUALIB_API int lua_dostring (lua_State *L, const char *str);
LUALIB_API int lua_dobuffer (lua_State *L, const char *buff, size_t sz,
const char *n);
#endif

View File

@ -1,5 +1,5 @@
/*
** $Id: ldblib.c,v 1.84 2003/11/05 11:59:14 roberto Exp roberto $
** $Id: ldblib.c,v 1.85 2004/04/30 20:13:38 roberto Exp roberto $
** Interface from Lua to its debug API
** See Copyright Notice in lua.h
*/
@ -261,7 +261,11 @@ static int debug (lua_State *L) {
if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
strcmp(buffer, "cont\n") == 0)
return 0;
lua_dostring(L, buffer);
if (luaL_loadbuffer(L, buffer, strlen(buffer), "=debug command") ||
lua_pcall(L, 0, 0, 0)) {
fputs(lua_tostring(L, -1), stderr);
fputs("\n", stderr);
}
lua_settop(L, 0); /* remove eventual returns */
}
}