aboutsummaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-03-19 18:16:12 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2003-03-19 18:16:12 -0300
commit1a553f9199f99bd529c542ef3be60b7a48f4ff2a (patch)
tree1401242d2d2e2fc96fd3de2034ecec84ee2eb231 /liolib.c
parent0ca225d33a34377d8339aa562422c0a2918891e2 (diff)
downloadlua-1a553f9199f99bd529c542ef3be60b7a48f4ff2a.tar.gz
lua-1a553f9199f99bd529c542ef3be60b7a48f4ff2a.tar.bz2
lua-1a553f9199f99bd529c542ef3be60b7a48f4ff2a.zip
better error messages
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/liolib.c b/liolib.c
index ad5b93d1..db6b3594 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 2.37 2003/03/14 19:08:11 roberto Exp roberto $ 2** $Id: liolib.c,v 2.38 2003/03/18 12:25:32 roberto Exp roberto $
3** Standard I/O (and system) library 3** Standard I/O (and system) library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -377,8 +377,7 @@ static int g_read (lua_State *L, FILE *f, int first) {
377 } 377 }
378 else { 378 else {
379 const char *p = lua_tostring(L, n); 379 const char *p = lua_tostring(L, n);
380 if (!p || p[0] != '*') 380 luaL_argcheck(L, p && p[0] == '*', n, "invalid option");
381 return luaL_error(L, "invalid `read' option");
382 switch (p[1]) { 381 switch (p[1]) {
383 case 'n': /* number */ 382 case 'n': /* number */
384 success = read_number(L, f); 383 success = read_number(L, f);
@@ -391,7 +390,7 @@ static int g_read (lua_State *L, FILE *f, int first) {
391 success = 1; /* always success */ 390 success = 1; /* always success */
392 break; 391 break;
393 case 'w': /* word */ 392 case 'w': /* word */
394 return luaL_error(L, "obsolete option `*w'"); 393 return luaL_error(L, "obsolete option `*w' to `read'");
395 default: 394 default:
396 return luaL_argerror(L, n, "invalid format"); 395 return luaL_argerror(L, n, "invalid format");
397 } 396 }
@@ -563,7 +562,7 @@ static int io_tmpname (lua_State *L) {
563#else 562#else
564 char buff[L_tmpnam]; 563 char buff[L_tmpnam];
565 if (tmpnam(buff) != buff) 564 if (tmpnam(buff) != buff)
566 return luaL_error(L, "unable to generate a unique filename"); 565 return luaL_error(L, "unable to generate a unique filename in `tmpname'");
567 lua_pushstring(L, buff); 566 lua_pushstring(L, buff);
568 return 1; 567 return 1;
569#endif 568#endif