diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-05-31 16:27:14 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-05-31 16:27:14 -0300 |
commit | 1e0aaf2156bb261787606b8cf00f812d75344ff2 (patch) | |
tree | b9a63fff3455cc1c09f0e4d820855e47b0e8c997 /lauxlib.c | |
parent | 616438fe9ab5e3ae7d73e9ad838e9b7bdea1ea59 (diff) | |
download | lua-1e0aaf2156bb261787606b8cf00f812d75344ff2.tar.gz lua-1e0aaf2156bb261787606b8cf00f812d75344ff2.tar.bz2 lua-1e0aaf2156bb261787606b8cf00f812d75344ff2.zip |
`luaL_dofile' and `luaL_dostring' are deprecated
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 51 |
1 files changed, 2 insertions, 49 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.111 2004/04/30 20:13:38 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.112 2004/05/10 17:50:51 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 | */ |
@@ -555,6 +555,7 @@ LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size, | |||
555 | return lua_load(L, getS, &ls, name); | 555 | return lua_load(L, getS, &ls, name); |
556 | } | 556 | } |
557 | 557 | ||
558 | |||
558 | /* }====================================================== */ | 559 | /* }====================================================== */ |
559 | 560 | ||
560 | 561 | ||
@@ -573,51 +574,3 @@ LUALIB_API lua_State *luaL_newstate (void) { | |||
573 | return lua_newstate(l_alloc, NULL); | 574 | return lua_newstate(l_alloc, NULL); |
574 | } | 575 | } |
575 | 576 | ||
576 | |||
577 | /* | ||
578 | ** {====================================================== | ||
579 | ** compatibility code | ||
580 | ** ======================================================= | ||
581 | */ | ||
582 | |||
583 | |||
584 | static void callalert (lua_State *L, int status) { | ||
585 | if (status != 0) { | ||
586 | lua_getglobal(L, "_ALERT"); | ||
587 | if (lua_isfunction(L, -1)) { | ||
588 | lua_insert(L, -2); | ||
589 | lua_call(L, 1, 0); | ||
590 | } | ||
591 | else { /* no _ALERT function; print it on stderr */ | ||
592 | fprintf(stderr, "%s\n", lua_tostring(L, -2)); | ||
593 | lua_pop(L, 2); /* remove error message and _ALERT */ | ||
594 | } | ||
595 | } | ||
596 | } | ||
597 | |||
598 | |||
599 | static int aux_do (lua_State *L, int status) { | ||
600 | if (status == 0) { /* parse OK? */ | ||
601 | status = lua_pcall(L, 0, LUA_MULTRET, 0); /* call main */ | ||
602 | } | ||
603 | callalert(L, status); | ||
604 | return status; | ||
605 | } | ||
606 | |||
607 | |||
608 | LUALIB_API int lua_dofile (lua_State *L, const char *filename) { | ||
609 | return aux_do(L, luaL_loadfile(L, filename)); | ||
610 | } | ||
611 | |||
612 | |||
613 | LUALIB_API int lua_dobuffer (lua_State *L, const char *buff, size_t size, | ||
614 | const char *name) { | ||
615 | return aux_do(L, luaL_loadbuffer(L, buff, size, name)); | ||
616 | } | ||
617 | |||
618 | |||
619 | LUALIB_API int lua_dostring (lua_State *L, const char *str) { | ||
620 | return lua_dobuffer(L, str, strlen(str), str); | ||
621 | } | ||
622 | |||
623 | /* }====================================================== */ | ||