mirror of https://github.com/rusefi/lua.git
new macro 'luai_writestringerror'
This commit is contained in:
parent
0d7d559dcc
commit
4274738e81
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lauxlib.c,v 1.197 2010/01/21 16:49:21 roberto Exp roberto $
|
||||
** $Id: lauxlib.c,v 1.198 2010/02/11 15:52:50 roberto Exp roberto $
|
||||
** Auxiliary functions for building Lua libraries
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -739,7 +739,7 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
|
|||
|
||||
|
||||
static int panic (lua_State *L) {
|
||||
fprintf(stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
|
||||
luai_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n",
|
||||
lua_tostring(L, -1));
|
||||
return 0; /* return to Lua to abort */
|
||||
}
|
||||
|
|
10
ldblib.c
10
ldblib.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ldblib.c,v 1.118 2009/11/25 15:27:51 roberto Exp roberto $
|
||||
** $Id: ldblib.c,v 1.119 2010/01/06 14:42:35 roberto Exp roberto $
|
||||
** Interface from Lua to its debug API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -339,15 +339,13 @@ static int db_gethook (lua_State *L) {
|
|||
static int db_debug (lua_State *L) {
|
||||
for (;;) {
|
||||
char buffer[250];
|
||||
fputs("lua_debug> ", stderr);
|
||||
luai_writestringerror("%s", "lua_debug> ");
|
||||
if (fgets(buffer, sizeof(buffer), stdin) == 0 ||
|
||||
strcmp(buffer, "cont\n") == 0)
|
||||
return 0;
|
||||
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_pcall(L, 0, 0, 0))
|
||||
luai_writestringerror("%s\n", lua_tostring(L, -1));
|
||||
lua_settop(L, 0); /* remove eventual returns */
|
||||
}
|
||||
}
|
||||
|
|
19
lua.c
19
lua.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lua.c,v 1.185 2010/02/09 11:58:57 roberto Exp roberto $
|
||||
** $Id: lua.c,v 1.186 2010/02/11 17:12:27 roberto Exp roberto $
|
||||
** Lua stand-alone interpreter
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -103,11 +103,14 @@ static void laction (int i) {
|
|||
|
||||
|
||||
static void print_usage (const char *badoption) {
|
||||
if (badoption[1] == 'e' || badoption[1] == 'l')
|
||||
fprintf(stderr, "%s: '%s' needs argument\n", progname, badoption);
|
||||
else
|
||||
fprintf(stderr, "%s: unrecognized option '%s'\n", progname, badoption);
|
||||
fprintf(stderr,
|
||||
if (badoption[1] == 'e' || badoption[1] == 'l') {
|
||||
luai_writestringerror("%s: ", progname);
|
||||
luai_writestringerror("'%s' needs argument\n", badoption);
|
||||
} else {
|
||||
luai_writestringerror("%s: ", progname);
|
||||
luai_writestringerror("unrecognized option '%s'\n", badoption);
|
||||
}
|
||||
luai_writestringerror(
|
||||
"usage: %s [options] [script [args]]\n"
|
||||
"Available options are:\n"
|
||||
" -e stat execute string " LUA_QL("stat") "\n"
|
||||
|
@ -122,8 +125,8 @@ static void print_usage (const char *badoption) {
|
|||
|
||||
|
||||
static void l_message (const char *pname, const char *msg) {
|
||||
if (pname) fprintf(stderr, "%s: ", pname);
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
if (pname) luai_writestringerror("%s: ", pname);
|
||||
luai_writestringerror("%s\n", msg);
|
||||
}
|
||||
|
||||
|
||||
|
|
10
luaconf.h
10
luaconf.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: luaconf.h,v 1.131 2010/01/21 16:31:24 roberto Exp roberto $
|
||||
** $Id: luaconf.h,v 1.132 2010/01/21 16:49:21 roberto Exp roberto $
|
||||
** Configuration file for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -192,10 +192,16 @@
|
|||
|
||||
/*
|
||||
@@ luai_writestring defines how 'print' prints its results.
|
||||
** CHANGE it if your system does not have a useful stdout.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#define luai_writestring(s,l) fwrite((s), sizeof(char), (l), stdout)
|
||||
|
||||
/*
|
||||
@@ luai_writestringerror defines how to print error messages.
|
||||
** (A format string with one argument is enough for Lua...)
|
||||
*/
|
||||
#define luai_writestringerror(s,p) fprintf(stderr, (s), (p))
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue