aboutsummaryrefslogtreecommitdiff
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
parent0ca225d33a34377d8339aa562422c0a2918891e2 (diff)
downloadlua-1a553f9199f99bd529c542ef3be60b7a48f4ff2a.tar.gz
lua-1a553f9199f99bd529c542ef3be60b7a48f4ff2a.tar.bz2
lua-1a553f9199f99bd529c542ef3be60b7a48f4ff2a.zip
better error messages
-rw-r--r--liolib.c9
-rw-r--r--lstrlib.c6
2 files changed, 7 insertions, 8 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
diff --git a/lstrlib.c b/lstrlib.c
index 7d93422e..e1aee1fd 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.95 2003/03/11 12:24:34 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.96 2003/03/14 18:59:53 roberto Exp roberto $
3** Standard library for string operations and pattern-matching 3** Standard library for string operations and pattern-matching
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -695,7 +695,7 @@ static int str_format (lua_State *L) {
695 char buff[MAX_ITEM]; /* to store the formatted item */ 695 char buff[MAX_ITEM]; /* to store the formatted item */
696 int hasprecision = 0; 696 int hasprecision = 0;
697 if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$') 697 if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$')
698 return luaL_error(L, "obsolete `format' option (d$)"); 698 return luaL_error(L, "obsolete option (d$) to `format'");
699 arg++; 699 arg++;
700 strfrmt = scanformat(L, strfrmt, form, &hasprecision); 700 strfrmt = scanformat(L, strfrmt, form, &hasprecision);
701 switch (*strfrmt++) { 701 switch (*strfrmt++) {
@@ -732,7 +732,7 @@ static int str_format (lua_State *L) {
732 } 732 }
733 } 733 }
734 default: { /* also treat cases `pnLlh' */ 734 default: { /* also treat cases `pnLlh' */
735 return luaL_error(L, "invalid option in `format'"); 735 return luaL_error(L, "invalid option to `format'");
736 } 736 }
737 } 737 }
738 luaL_addlstring(&b, buff, strlen(buff)); 738 luaL_addlstring(&b, buff, strlen(buff));