From 1bdde38bd24b137a240aede92363837e3d1a79b9 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 5 Sep 2002 16:45:42 -0300 Subject: [PATCH] no more newlines at the end of error messages --- lauxlib.c | 5 ++--- lbaselib.c | 5 ++--- ldblib.c | 9 ++++----- ldebug.c | 11 ++++------- llex.c | 4 ++-- lua.c | 7 ++----- 6 files changed, 16 insertions(+), 25 deletions(-) diff --git a/lauxlib.c b/lauxlib.c index 65b1def3..84d7feaa 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.83 2002/08/08 20:08:41 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.84 2002/08/30 20:00:59 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -81,8 +81,7 @@ LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) { luaL_where(L, 1); lua_pushvfstring(L, fmt, argp); va_end(argp); - lua_pushliteral(L, "\n"); - lua_concat(L, 3); + lua_concat(L, 2); return lua_error(L); } diff --git a/lbaselib.c b/lbaselib.c index 16f84ec4..6baa5ccf 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.96 2002/08/06 18:54:18 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.97 2002/08/08 20:08:41 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -82,8 +82,7 @@ static int luaB_error (lua_State *L) { else { /* add extra information */ luaL_where(L, level); lua_pushvalue(L, 1); - lua_pushliteral(L, "\n"); - lua_concat(L, 3); + lua_concat(L, 2); } return lua_error(L); } diff --git a/ldblib.c b/ldblib.c index a8913fe8..7294ce97 100644 --- a/ldblib.c +++ b/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.67 2002/08/12 17:23:12 roberto Exp roberto $ +** $Id: ldblib.c,v 1.68 2002/08/16 14:45:18 roberto Exp roberto $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -198,21 +198,21 @@ static int errorfb (lua_State *L) { if (lua_gettop(L) == 0) lua_pushliteral(L, ""); else if (!lua_isstring(L, 1)) return 1; /* no string message */ - lua_pushliteral(L, "stack traceback:\n"); + lua_pushliteral(L, "\nstack traceback:"); while (lua_getstack(L, level++, &ar)) { if (level > LEVELS1 && firstpart) { /* no more than `LEVELS2' more levels? */ if (!lua_getstack(L, level+LEVELS2, &ar)) level--; /* keep going */ else { - lua_pushliteral(L, "\t...\n"); /* too many levels */ + lua_pushliteral(L, "\n\t..."); /* too many levels */ while (lua_getstack(L, level+LEVELS2, &ar)) /* find last levels */ level++; } firstpart = 0; continue; } - lua_pushliteral(L, "\t"); + lua_pushliteral(L, "\n\t"); lua_getinfo(L, "Snl", &ar); lua_pushfstring(L, "%s:", ar.short_src); if (ar.currentline > 0) @@ -234,7 +234,6 @@ static int errorfb (lua_State *L) { ar.short_src, ar.linedefined); } } - lua_pushliteral(L, "\n"); lua_concat(L, lua_gettop(L)); } lua_concat(L, lua_gettop(L)); diff --git a/ldebug.c b/ldebug.c index 55c53f9d..0cf0f963 100644 --- a/ldebug.c +++ b/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 1.132 2002/08/12 17:23:12 roberto Exp roberto $ +** $Id: ldebug.c,v 1.133 2002/08/20 20:03:05 roberto Exp roberto $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -524,14 +524,11 @@ int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { static void addinfo (lua_State *L, const char *msg) { CallInfo *ci = L->ci; - if (!isLua(ci)) { /* no Lua code? */ - luaO_pushfstring(L, "%s\n", msg); /* no extra info; just add '\n' */ - } - else { /* add file:line information */ - char buff[LUA_IDSIZE]; + if (isLua(ci)) { /* is Lua code? */ + char buff[LUA_IDSIZE]; /* add file:line information */ int line = currentline(ci); luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE); - luaO_pushfstring(L, "%s:%d: %s\n", buff, line, msg); + luaO_pushfstring(L, "%s:%d: %s", buff, line, msg); } } diff --git a/llex.c b/llex.c index 0dc47fd2..f0cf7146 100644 --- a/llex.c +++ b/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 1.109 2002/08/16 14:45:55 roberto Exp roberto $ +** $Id: llex.c,v 1.110 2002/09/03 11:57:38 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -61,7 +61,7 @@ static void luaX_error (LexState *ls, const char *s, const char *token) { lua_State *L = ls->L; char buff[MAXSRC]; luaO_chunkid(buff, getstr(ls->source), MAXSRC); - luaO_pushfstring(L, "%s:%d: %s near `%s'\n", buff, ls->linenumber, s, token); + luaO_pushfstring(L, "%s:%d: %s near `%s'", buff, ls->linenumber, s, token); luaD_throw(L, LUA_ERRSYNTAX); } diff --git a/lua.c b/lua.c index 85ce0803..eed8be8a 100644 --- a/lua.c +++ b/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.102 2002/08/12 17:23:12 roberto Exp roberto $ +** $Id: lua.c,v 1.103 2002/08/13 15:04:59 roberto Exp roberto $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -87,11 +87,8 @@ static void print_usage (void) { static void l_message (const char *pname, const char *msg) { - size_t l = strlen(msg); if (pname) fprintf(stderr, "%s: ", pname); - fprintf(stderr, "%s", msg); - if (l > 0 && msg[l-1] != '\n') /* does not end with newline? */ - fprintf(stderr, "\n"); /* add a newline */ + fprintf(stderr, "%s\n", msg); }