diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-05-02 14:12:27 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-05-02 14:12:27 -0300 |
commit | 85dcb411a8454de0bc1c2c60a24af1588e436c23 (patch) | |
tree | 169fc4cefe7ba02a46944a172660aff208b3e42e | |
parent | 3c6a383d6239629fd8858e0d59bcdab25138bcc1 (diff) | |
download | lua-85dcb411a8454de0bc1c2c60a24af1588e436c23.tar.gz lua-85dcb411a8454de0bc1c2c60a24af1588e436c23.tar.bz2 lua-85dcb411a8454de0bc1c2c60a24af1588e436c23.zip |
all textual errors go through `luaL_verror'
-rw-r--r-- | lbaselib.c | 10 | ||||
-rw-r--r-- | liolib.c | 12 | ||||
-rw-r--r-- | lmathlib.c | 4 | ||||
-rw-r--r-- | lstrlib.c | 24 | ||||
-rw-r--r-- | ltablib.c | 6 |
5 files changed, 28 insertions, 28 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.69 2002/04/22 14:40:23 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.70 2002/05/01 20:40:42 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 | */ |
@@ -72,7 +72,7 @@ static int luaB_print (lua_State *L) { | |||
72 | lua_rawcall(L, 1, 1); | 72 | lua_rawcall(L, 1, 1); |
73 | s = lua_tostring(L, -1); /* get result */ | 73 | s = lua_tostring(L, -1); /* get result */ |
74 | if (s == NULL) | 74 | if (s == NULL) |
75 | lua_error(L, "`tostring' must return a string to `print'"); | 75 | luaL_verror(L, "`tostring' must return a string to `print'"); |
76 | if (i>1) fputs("\t", stdout); | 76 | if (i>1) fputs("\t", stdout); |
77 | fputs(s, stdout); | 77 | fputs(s, stdout); |
78 | lua_pop(L, 1); /* pop result */ | 78 | lua_pop(L, 1); /* pop result */ |
@@ -372,7 +372,7 @@ static int luaB_require (lua_State *L) { | |||
372 | lua_pushvalue(L, 1); | 372 | lua_pushvalue(L, 1); |
373 | lua_setglobal(L, "_REQUIREDNAME"); | 373 | lua_setglobal(L, "_REQUIREDNAME"); |
374 | lua_getglobal(L, REQTAB); | 374 | lua_getglobal(L, REQTAB); |
375 | if (!lua_istable(L, 2)) lua_error(L, REQTAB " is not a table"); | 375 | if (!lua_istable(L, 2)) luaL_verror(L, REQTAB " is not a table"); |
376 | path = getpath(L); | 376 | path = getpath(L); |
377 | lua_pushvalue(L, 1); /* check package's name in book-keeping table */ | 377 | lua_pushvalue(L, 1); /* check package's name in book-keeping table */ |
378 | lua_gettable(L, 2); | 378 | lua_gettable(L, 2); |
@@ -399,7 +399,7 @@ static int luaB_require (lua_State *L) { | |||
399 | lua_tostring(L, 1), lua_tostring(L, 3)); | 399 | lua_tostring(L, 1), lua_tostring(L, 3)); |
400 | } | 400 | } |
401 | default: { | 401 | default: { |
402 | lua_error(L, "error loading package"); | 402 | luaL_verror(L, "error loading package"); |
403 | return 0; /* to avoid warnings */ | 403 | return 0; /* to avoid warnings */ |
404 | } | 404 | } |
405 | } | 405 | } |
@@ -466,7 +466,7 @@ static int luaB_coroutine (lua_State *L) { | |||
466 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, | 466 | luaL_arg_check(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, |
467 | "Lua function expected"); | 467 | "Lua function expected"); |
468 | NL = lua_newthread(L); | 468 | NL = lua_newthread(L); |
469 | if (NL == NULL) lua_error(L, "unable to create new thread"); | 469 | if (NL == NULL) luaL_verror(L, "unable to create new thread"); |
470 | /* move function and arguments from L to NL */ | 470 | /* move function and arguments from L to NL */ |
471 | for (i=0; i<n; i++) { | 471 | for (i=0; i<n; i++) { |
472 | ref = lua_ref(L, 1); | 472 | ref = lua_ref(L, 1); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.2 2002/04/05 18:54:31 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.3 2002/04/12 19:56:25 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 | */ |
@@ -118,7 +118,7 @@ static int io_open (lua_State *L) { | |||
118 | 118 | ||
119 | static int io_popen (lua_State *L) { | 119 | static int io_popen (lua_State *L) { |
120 | #ifndef POPEN | 120 | #ifndef POPEN |
121 | lua_error(L, "`popen' not supported"); | 121 | luaL_verror(L, "`popen' not supported"); |
122 | return 0; | 122 | return 0; |
123 | #else | 123 | #else |
124 | FILE *f = popen(luaL_check_string(L, 1), luaL_opt_string(L, 2, "r")); | 124 | FILE *f = popen(luaL_check_string(L, 1), luaL_opt_string(L, 2, "r")); |
@@ -257,7 +257,7 @@ static int g_read (lua_State *L, FILE *f, int first) { | |||
257 | else { | 257 | else { |
258 | const char *p = lua_tostring(L, n); | 258 | const char *p = lua_tostring(L, n); |
259 | if (!p || p[0] != '*') | 259 | if (!p || p[0] != '*') |
260 | lua_error(L, "invalid `read' option"); | 260 | luaL_verror(L, "invalid `read' option"); |
261 | switch (p[1]) { | 261 | switch (p[1]) { |
262 | case 'n': /* number */ | 262 | case 'n': /* number */ |
263 | success = read_number(L, f); | 263 | success = read_number(L, f); |
@@ -270,7 +270,7 @@ static int g_read (lua_State *L, FILE *f, int first) { | |||
270 | success = 1; /* always success */ | 270 | success = 1; /* always success */ |
271 | break; | 271 | break; |
272 | case 'w': /* word */ | 272 | case 'w': /* word */ |
273 | lua_error(L, "obsolete option `*w'"); | 273 | luaL_verror(L, "obsolete option `*w'"); |
274 | break; | 274 | break; |
275 | default: | 275 | default: |
276 | luaL_argerror(L, n, "invalid format"); | 276 | luaL_argerror(L, n, "invalid format"); |
@@ -430,7 +430,7 @@ static int io_rename (lua_State *L) { | |||
430 | static int io_tmpname (lua_State *L) { | 430 | static int io_tmpname (lua_State *L) { |
431 | char buff[L_tmpnam]; | 431 | char buff[L_tmpnam]; |
432 | if (tmpnam(buff) != buff) | 432 | if (tmpnam(buff) != buff) |
433 | lua_error(L, "unable to generate a unique filename"); | 433 | luaL_verror(L, "unable to generate a unique filename"); |
434 | lua_pushstring(L, buff); | 434 | lua_pushstring(L, buff); |
435 | return 1; | 435 | return 1; |
436 | } | 436 | } |
@@ -510,7 +510,7 @@ static int io_date (lua_State *L) { | |||
510 | if (strftime(b, sizeof(b), s, stm)) | 510 | if (strftime(b, sizeof(b), s, stm)) |
511 | lua_pushstring(L, b); | 511 | lua_pushstring(L, b); |
512 | else | 512 | else |
513 | lua_error(L, "invalid `date' format"); | 513 | luaL_verror(L, "invalid `date' format"); |
514 | } | 514 | } |
515 | return 1; | 515 | return 1; |
516 | } | 516 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.42 2002/04/02 20:41:59 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.43 2002/04/04 20:20:49 roberto Exp roberto $ |
3 | ** Standard mathematical library | 3 | ** Standard mathematical library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -187,7 +187,7 @@ static int math_random (lua_State *L) { | |||
187 | lua_pushnumber(L, (int)(r*(u-l+1))+l); /* integer between `l' and `u' */ | 187 | lua_pushnumber(L, (int)(r*(u-l+1))+l); /* integer between `l' and `u' */ |
188 | break; | 188 | break; |
189 | } | 189 | } |
190 | default: lua_error(L, "wrong number of arguments"); | 190 | default: luaL_verror(L, "wrong number of arguments"); |
191 | } | 191 | } |
192 | return 1; | 192 | return 1; |
193 | } | 193 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.79 2002/03/20 12:54:08 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.80 2002/04/02 20:41:59 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 | */ |
@@ -170,7 +170,7 @@ typedef struct MatchState { | |||
170 | static int check_capture (MatchState *ms, int l) { | 170 | static int check_capture (MatchState *ms, int l) { |
171 | l -= '1'; | 171 | l -= '1'; |
172 | if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) | 172 | if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) |
173 | lua_error(ms->L, "invalid capture index"); | 173 | luaL_verror(ms->L, "invalid capture index"); |
174 | return l; | 174 | return l; |
175 | } | 175 | } |
176 | 176 | ||
@@ -179,7 +179,7 @@ static int capture_to_close (MatchState *ms) { | |||
179 | int level = ms->level; | 179 | int level = ms->level; |
180 | for (level--; level>=0; level--) | 180 | for (level--; level>=0; level--) |
181 | if (ms->capture[level].len == CAP_UNFINISHED) return level; | 181 | if (ms->capture[level].len == CAP_UNFINISHED) return level; |
182 | lua_error(ms->L, "invalid pattern capture"); | 182 | luaL_verror(ms->L, "invalid pattern capture"); |
183 | return 0; /* to avoid warnings */ | 183 | return 0; /* to avoid warnings */ |
184 | } | 184 | } |
185 | 185 | ||
@@ -188,13 +188,13 @@ static const char *luaI_classend (MatchState *ms, const char *p) { | |||
188 | switch (*p++) { | 188 | switch (*p++) { |
189 | case ESC: | 189 | case ESC: |
190 | if (*p == '\0') | 190 | if (*p == '\0') |
191 | lua_error(ms->L, "malformed pattern (ends with `%')"); | 191 | luaL_verror(ms->L, "malformed pattern (ends with `%')"); |
192 | return p+1; | 192 | return p+1; |
193 | case '[': | 193 | case '[': |
194 | if (*p == '^') p++; | 194 | if (*p == '^') p++; |
195 | do { /* look for a `]' */ | 195 | do { /* look for a `]' */ |
196 | if (*p == '\0') | 196 | if (*p == '\0') |
197 | lua_error(ms->L, "malformed pattern (missing `]')"); | 197 | luaL_verror(ms->L, "malformed pattern (missing `]')"); |
198 | if (*(p++) == ESC && *p != '\0') | 198 | if (*(p++) == ESC && *p != '\0') |
199 | p++; /* skip escapes (e.g. `%]') */ | 199 | p++; /* skip escapes (e.g. `%]') */ |
200 | } while (*p != ']'); | 200 | } while (*p != ']'); |
@@ -267,7 +267,7 @@ static const char *match (MatchState *ms, const char *s, const char *p); | |||
267 | static const char *matchbalance (MatchState *ms, const char *s, | 267 | static const char *matchbalance (MatchState *ms, const char *s, |
268 | const char *p) { | 268 | const char *p) { |
269 | if (*p == 0 || *(p+1) == 0) | 269 | if (*p == 0 || *(p+1) == 0) |
270 | lua_error(ms->L, "unbalanced pattern"); | 270 | luaL_verror(ms->L, "unbalanced pattern"); |
271 | if (*s != *p) return NULL; | 271 | if (*s != *p) return NULL; |
272 | else { | 272 | else { |
273 | int b = *p; | 273 | int b = *p; |
@@ -316,7 +316,7 @@ static const char *start_capture (MatchState *ms, const char *s, | |||
316 | const char *p, int what) { | 316 | const char *p, int what) { |
317 | const char *res; | 317 | const char *res; |
318 | int level = ms->level; | 318 | int level = ms->level; |
319 | if (level >= MAX_CAPTURES) lua_error(ms->L, "too many captures"); | 319 | if (level >= MAX_CAPTURES) luaL_verror(ms->L, "too many captures"); |
320 | ms->capture[level].init = s; | 320 | ms->capture[level].init = s; |
321 | ms->capture[level].len = what; | 321 | ms->capture[level].len = what; |
322 | ms->level = level+1; | 322 | ms->level = level+1; |
@@ -426,7 +426,7 @@ static const char *lmemfind (const char *s1, size_t l1, | |||
426 | 426 | ||
427 | static void push_onecapture (MatchState *ms, int i) { | 427 | static void push_onecapture (MatchState *ms, int i) { |
428 | int l = ms->capture[i].len; | 428 | int l = ms->capture[i].len; |
429 | if (l == CAP_UNFINISHED) lua_error(ms->L, "unfinished capture"); | 429 | if (l == CAP_UNFINISHED) luaL_verror(ms->L, "unfinished capture"); |
430 | if (l == CAP_POSITION) | 430 | if (l == CAP_POSITION) |
431 | lua_pushnumber(ms->L, ms->capture[i].init - ms->src_init + 1); | 431 | lua_pushnumber(ms->L, ms->capture[i].init - ms->src_init + 1); |
432 | else | 432 | else |
@@ -636,9 +636,9 @@ static const char *scanformat (lua_State *L, const char *strfrmt, | |||
636 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ | 636 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ |
637 | } | 637 | } |
638 | if (isdigit(uchar(*p))) | 638 | if (isdigit(uchar(*p))) |
639 | lua_error(L, "invalid format (width or precision too long)"); | 639 | luaL_verror(L, "invalid format (width or precision too long)"); |
640 | if (p-strfrmt+2 > MAX_FORMAT) /* +2 to include `%' and the specifier */ | 640 | if (p-strfrmt+2 > MAX_FORMAT) /* +2 to include `%' and the specifier */ |
641 | lua_error(L, "invalid format (too long)"); | 641 | luaL_verror(L, "invalid format (too long)"); |
642 | form[0] = '%'; | 642 | form[0] = '%'; |
643 | strncpy(form+1, strfrmt, p-strfrmt+1); | 643 | strncpy(form+1, strfrmt, p-strfrmt+1); |
644 | form[p-strfrmt+2] = 0; | 644 | form[p-strfrmt+2] = 0; |
@@ -663,7 +663,7 @@ static int str_format (lua_State *L) { | |||
663 | char buff[MAX_ITEM]; /* to store the formatted item */ | 663 | char buff[MAX_ITEM]; /* to store the formatted item */ |
664 | int hasprecision = 0; | 664 | int hasprecision = 0; |
665 | if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$') | 665 | if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$') |
666 | lua_error(L, "obsolete `format' option (d$)"); | 666 | luaL_verror(L, "obsolete `format' option (d$)"); |
667 | arg++; | 667 | arg++; |
668 | strfrmt = scanformat(L, strfrmt, form, &hasprecision); | 668 | strfrmt = scanformat(L, strfrmt, form, &hasprecision); |
669 | switch (*strfrmt++) { | 669 | switch (*strfrmt++) { |
@@ -696,7 +696,7 @@ static int str_format (lua_State *L) { | |||
696 | } | 696 | } |
697 | } | 697 | } |
698 | default: /* also treat cases `pnLlh' */ | 698 | default: /* also treat cases `pnLlh' */ |
699 | lua_error(L, "invalid option in `format'"); | 699 | luaL_verror(L, "invalid option in `format'"); |
700 | } | 700 | } |
701 | luaL_addlstring(&b, buff, strlen(buff)); | 701 | luaL_addlstring(&b, buff, strlen(buff)); |
702 | } | 702 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltablib.c,v 1.1 2002/04/09 20:19:06 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.2 2002/04/12 19:57:29 roberto Exp roberto $ |
3 | ** Library for Table Manipulation | 3 | ** Library for Table Manipulation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -171,12 +171,12 @@ static void auxsort (lua_State *L, int l, int u) { | |||
171 | for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */ | 171 | for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */ |
172 | /* repeat ++i until a[i] >= P */ | 172 | /* repeat ++i until a[i] >= P */ |
173 | while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { | 173 | while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) { |
174 | if (i>u) lua_error(L, "invalid order function for sorting"); | 174 | if (i>u) luaL_verror(L, "invalid order function for sorting"); |
175 | lua_pop(L, 1); /* remove a[i] */ | 175 | lua_pop(L, 1); /* remove a[i] */ |
176 | } | 176 | } |
177 | /* repeat --j until a[j] <= P */ | 177 | /* repeat --j until a[j] <= P */ |
178 | while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { | 178 | while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) { |
179 | if (j<l) lua_error(L, "invalid order function for sorting"); | 179 | if (j<l) luaL_verror(L, "invalid order function for sorting"); |
180 | lua_pop(L, 1); /* remove a[j] */ | 180 | lua_pop(L, 1); /* remove a[j] */ |
181 | } | 181 | } |
182 | if (j<i) { | 182 | if (j<i) { |