aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-09-05 16:45:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-09-05 16:45:42 -0300
commit1bdde38bd24b137a240aede92363837e3d1a79b9 (patch)
treefeb4d9bc8c4dc3c3bf815bd1d21b837c92debf59
parentb2bc3b44b6bdf5efd783a50c28e108ac3bcba9fd (diff)
downloadlua-1bdde38bd24b137a240aede92363837e3d1a79b9.tar.gz
lua-1bdde38bd24b137a240aede92363837e3d1a79b9.tar.bz2
lua-1bdde38bd24b137a240aede92363837e3d1a79b9.zip
no more newlines at the end of error messages
-rw-r--r--lauxlib.c5
-rw-r--r--lbaselib.c5
-rw-r--r--ldblib.c9
-rw-r--r--ldebug.c11
-rw-r--r--llex.c4
-rw-r--r--lua.c7
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 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.83 2002/08/08 20:08:41 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.84 2002/08/30 20:00:59 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*/
@@ -81,8 +81,7 @@ LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
81 luaL_where(L, 1); 81 luaL_where(L, 1);
82 lua_pushvfstring(L, fmt, argp); 82 lua_pushvfstring(L, fmt, argp);
83 va_end(argp); 83 va_end(argp);
84 lua_pushliteral(L, "\n"); 84 lua_concat(L, 2);
85 lua_concat(L, 3);
86 return lua_error(L); 85 return lua_error(L);
87} 86}
88 87
diff --git a/lbaselib.c b/lbaselib.c
index 16f84ec4..6baa5ccf 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.96 2002/08/06 18:54:18 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.97 2002/08/08 20:08:41 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -82,8 +82,7 @@ static int luaB_error (lua_State *L) {
82 else { /* add extra information */ 82 else { /* add extra information */
83 luaL_where(L, level); 83 luaL_where(L, level);
84 lua_pushvalue(L, 1); 84 lua_pushvalue(L, 1);
85 lua_pushliteral(L, "\n"); 85 lua_concat(L, 2);
86 lua_concat(L, 3);
87 } 86 }
88 return lua_error(L); 87 return lua_error(L);
89} 88}
diff --git a/ldblib.c b/ldblib.c
index a8913fe8..7294ce97 100644
--- a/ldblib.c
+++ b/ldblib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldblib.c,v 1.67 2002/08/12 17:23:12 roberto Exp roberto $ 2** $Id: ldblib.c,v 1.68 2002/08/16 14:45:18 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*/
@@ -198,21 +198,21 @@ static int errorfb (lua_State *L) {
198 if (lua_gettop(L) == 0) 198 if (lua_gettop(L) == 0)
199 lua_pushliteral(L, ""); 199 lua_pushliteral(L, "");
200 else if (!lua_isstring(L, 1)) return 1; /* no string message */ 200 else if (!lua_isstring(L, 1)) return 1; /* no string message */
201 lua_pushliteral(L, "stack traceback:\n"); 201 lua_pushliteral(L, "\nstack traceback:");
202 while (lua_getstack(L, level++, &ar)) { 202 while (lua_getstack(L, level++, &ar)) {
203 if (level > LEVELS1 && firstpart) { 203 if (level > LEVELS1 && firstpart) {
204 /* no more than `LEVELS2' more levels? */ 204 /* no more than `LEVELS2' more levels? */
205 if (!lua_getstack(L, level+LEVELS2, &ar)) 205 if (!lua_getstack(L, level+LEVELS2, &ar))
206 level--; /* keep going */ 206 level--; /* keep going */
207 else { 207 else {
208 lua_pushliteral(L, "\t...\n"); /* too many levels */ 208 lua_pushliteral(L, "\n\t..."); /* too many levels */
209 while (lua_getstack(L, level+LEVELS2, &ar)) /* find last levels */ 209 while (lua_getstack(L, level+LEVELS2, &ar)) /* find last levels */
210 level++; 210 level++;
211 } 211 }
212 firstpart = 0; 212 firstpart = 0;
213 continue; 213 continue;
214 } 214 }
215 lua_pushliteral(L, "\t"); 215 lua_pushliteral(L, "\n\t");
216 lua_getinfo(L, "Snl", &ar); 216 lua_getinfo(L, "Snl", &ar);
217 lua_pushfstring(L, "%s:", ar.short_src); 217 lua_pushfstring(L, "%s:", ar.short_src);
218 if (ar.currentline > 0) 218 if (ar.currentline > 0)
@@ -234,7 +234,6 @@ static int errorfb (lua_State *L) {
234 ar.short_src, ar.linedefined); 234 ar.short_src, ar.linedefined);
235 } 235 }
236 } 236 }
237 lua_pushliteral(L, "\n");
238 lua_concat(L, lua_gettop(L)); 237 lua_concat(L, lua_gettop(L));
239 } 238 }
240 lua_concat(L, lua_gettop(L)); 239 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 @@
1/* 1/*
2** $Id: ldebug.c,v 1.132 2002/08/12 17:23:12 roberto Exp roberto $ 2** $Id: ldebug.c,v 1.133 2002/08/20 20:03:05 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -524,14 +524,11 @@ int luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) {
524 524
525static void addinfo (lua_State *L, const char *msg) { 525static void addinfo (lua_State *L, const char *msg) {
526 CallInfo *ci = L->ci; 526 CallInfo *ci = L->ci;
527 if (!isLua(ci)) { /* no Lua code? */ 527 if (isLua(ci)) { /* is Lua code? */
528 luaO_pushfstring(L, "%s\n", msg); /* no extra info; just add '\n' */ 528 char buff[LUA_IDSIZE]; /* add file:line information */
529 }
530 else { /* add file:line information */
531 char buff[LUA_IDSIZE];
532 int line = currentline(ci); 529 int line = currentline(ci);
533 luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE); 530 luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE);
534 luaO_pushfstring(L, "%s:%d: %s\n", buff, line, msg); 531 luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
535 } 532 }
536} 533}
537 534
diff --git a/llex.c b/llex.c
index 0dc47fd2..f0cf7146 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 1.109 2002/08/16 14:45:55 roberto Exp roberto $ 2** $Id: llex.c,v 1.110 2002/09/03 11:57:38 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -61,7 +61,7 @@ static void luaX_error (LexState *ls, const char *s, const char *token) {
61 lua_State *L = ls->L; 61 lua_State *L = ls->L;
62 char buff[MAXSRC]; 62 char buff[MAXSRC];
63 luaO_chunkid(buff, getstr(ls->source), MAXSRC); 63 luaO_chunkid(buff, getstr(ls->source), MAXSRC);
64 luaO_pushfstring(L, "%s:%d: %s near `%s'\n", buff, ls->linenumber, s, token); 64 luaO_pushfstring(L, "%s:%d: %s near `%s'", buff, ls->linenumber, s, token);
65 luaD_throw(L, LUA_ERRSYNTAX); 65 luaD_throw(L, LUA_ERRSYNTAX);
66} 66}
67 67
diff --git a/lua.c b/lua.c
index 85ce0803..eed8be8a 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.102 2002/08/12 17:23:12 roberto Exp roberto $ 2** $Id: lua.c,v 1.103 2002/08/13 15:04:59 roberto Exp roberto $
3** Lua stand-alone interpreter 3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -87,11 +87,8 @@ static void print_usage (void) {
87 87
88 88
89static void l_message (const char *pname, const char *msg) { 89static void l_message (const char *pname, const char *msg) {
90 size_t l = strlen(msg);
91 if (pname) fprintf(stderr, "%s: ", pname); 90 if (pname) fprintf(stderr, "%s: ", pname);
92 fprintf(stderr, "%s", msg); 91 fprintf(stderr, "%s\n", msg);
93 if (l > 0 && msg[l-1] != '\n') /* does not end with newline? */
94 fprintf(stderr, "\n"); /* add a newline */
95} 92}
96 93
97 94