aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lauxlib.c51
-rw-r--r--lauxlib.h13
-rw-r--r--ldblib.c8
3 files changed, 9 insertions, 63 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 6ff2940f..ce16c42f 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -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
584static 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
599static 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
608LUALIB_API int lua_dofile (lua_State *L, const char *filename) {
609 return aux_do(L, luaL_loadfile(L, filename));
610}
611
612
613LUALIB_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
619LUALIB_API int lua_dostring (lua_State *L, const char *str) {
620 return lua_dobuffer(L, str, strlen(str), str);
621}
622
623/* }====================================================== */
diff --git a/lauxlib.h b/lauxlib.h
index 6ccaf2dc..23e99496 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -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
121LUALIB_API int lua_dofile (lua_State *L, const char *filename);
122LUALIB_API int lua_dostring (lua_State *L, const char *str);
123LUALIB_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
diff --git a/ldblib.c b/ldblib.c
index 2e121aa9..af575bd7 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -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}