diff options
-rw-r--r-- | lauxlib.c | 51 | ||||
-rw-r--r-- | lauxlib.h | 13 | ||||
-rw-r--r-- | ldblib.c | 8 |
3 files changed, 9 insertions, 63 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 | /* }====================================================== */ | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.h,v 1.63 2004/03/13 13:32:09 roberto Exp roberto $ | 2 | ** $Id: lauxlib.h,v 1.64 2004/05/03 12:28:43 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 | */ |
@@ -113,17 +113,6 @@ LUALIB_API void luaL_pushresult (luaL_Buffer *B); | |||
113 | /* }====================================================== */ | 113 | /* }====================================================== */ |
114 | 114 | ||
115 | 115 | ||
116 | |||
117 | /* | ||
118 | ** Compatibility macros and functions | ||
119 | */ | ||
120 | |||
121 | LUALIB_API int lua_dofile (lua_State *L, const char *filename); | ||
122 | LUALIB_API int lua_dostring (lua_State *L, const char *str); | ||
123 | LUALIB_API int lua_dobuffer (lua_State *L, const char *buff, size_t sz, | ||
124 | const char *n); | ||
125 | |||
126 | |||
127 | #endif | 116 | #endif |
128 | 117 | ||
129 | 118 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.84 2003/11/05 11:59:14 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.85 2004/04/30 20:13:38 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -261,7 +261,11 @@ static int debug (lua_State *L) { | |||
261 | if (fgets(buffer, sizeof(buffer), stdin) == 0 || | 261 | if (fgets(buffer, sizeof(buffer), stdin) == 0 || |
262 | strcmp(buffer, "cont\n") == 0) | 262 | strcmp(buffer, "cont\n") == 0) |
263 | return 0; | 263 | return 0; |
264 | lua_dostring(L, buffer); | 264 | if (luaL_loadbuffer(L, buffer, strlen(buffer), "=debug command") || |
265 | lua_pcall(L, 0, 0, 0)) { | ||
266 | fputs(lua_tostring(L, -1), stderr); | ||
267 | fputs("\n", stderr); | ||
268 | } | ||
265 | lua_settop(L, 0); /* remove eventual returns */ | 269 | lua_settop(L, 0); /* remove eventual returns */ |
266 | } | 270 | } |
267 | } | 271 | } |