diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-18 12:16:18 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-18 12:16:18 -0300 |
commit | d8678edddc98beab8eb78e63e698191a9ffd39b8 (patch) | |
tree | fa8b5e3595f0caa11fb8ee5bfc3412e76dbef230 | |
parent | e812aa200234629d89351b6653d6ae737478ccd8 (diff) | |
download | lua-d8678edddc98beab8eb78e63e698191a9ffd39b8.tar.gz lua-d8678edddc98beab8eb78e63e698191a9ffd39b8.tar.bz2 lua-d8678edddc98beab8eb78e63e698191a9ffd39b8.zip |
luaL_verror -> luaL_error
-rw-r--r-- | liolib.c | 16 | ||||
-rw-r--r-- | lmathlib.c | 4 | ||||
-rw-r--r-- | lstrlib.c | 24 | ||||
-rw-r--r-- | ltablib.c | 6 |
4 files changed, 25 insertions, 25 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.9 2002/06/06 12:43:08 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.10 2002/06/06 18:17:33 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 | */ |
@@ -124,7 +124,7 @@ static int io_open (lua_State *L) { | |||
124 | 124 | ||
125 | static int io_popen (lua_State *L) { | 125 | static int io_popen (lua_State *L) { |
126 | #ifndef POPEN | 126 | #ifndef POPEN |
127 | luaL_verror(L, "`popen' not supported"); | 127 | luaL_error(L, "`popen' not supported"); |
128 | return 0; | 128 | return 0; |
129 | #else | 129 | #else |
130 | FILE *f = popen(luaL_check_string(L, 1), luaL_opt_string(L, 2, "r")); | 130 | FILE *f = popen(luaL_check_string(L, 1), luaL_opt_string(L, 2, "r")); |
@@ -144,7 +144,7 @@ static FILE *getiofile (lua_State *L, const char *name) { | |||
144 | lua_rawget(L, lua_upvalueindex(1)); | 144 | lua_rawget(L, lua_upvalueindex(1)); |
145 | f = tofile(L, -1); | 145 | f = tofile(L, -1); |
146 | if (f == NULL) | 146 | if (f == NULL) |
147 | luaL_verror(L, "%s is closed", name); | 147 | luaL_error(L, "%s is closed", name); |
148 | return f; | 148 | return f; |
149 | } | 149 | } |
150 | 150 | ||
@@ -267,7 +267,7 @@ static int g_read (lua_State *L, FILE *f, int first) { | |||
267 | else { | 267 | else { |
268 | const char *p = lua_tostring(L, n); | 268 | const char *p = lua_tostring(L, n); |
269 | if (!p || p[0] != '*') | 269 | if (!p || p[0] != '*') |
270 | return luaL_verror(L, "invalid `read' option"); | 270 | return luaL_error(L, "invalid `read' option"); |
271 | switch (p[1]) { | 271 | switch (p[1]) { |
272 | case 'n': /* number */ | 272 | case 'n': /* number */ |
273 | success = read_number(L, f); | 273 | success = read_number(L, f); |
@@ -280,7 +280,7 @@ static int g_read (lua_State *L, FILE *f, int first) { | |||
280 | success = 1; /* always success */ | 280 | success = 1; /* always success */ |
281 | break; | 281 | break; |
282 | case 'w': /* word */ | 282 | case 'w': /* word */ |
283 | return luaL_verror(L, "obsolete option `*w'"); | 283 | return luaL_error(L, "obsolete option `*w'"); |
284 | default: | 284 | default: |
285 | return luaL_argerror(L, n, "invalid format"); | 285 | return luaL_argerror(L, n, "invalid format"); |
286 | } | 286 | } |
@@ -439,7 +439,7 @@ static int io_rename (lua_State *L) { | |||
439 | static int io_tmpname (lua_State *L) { | 439 | static int io_tmpname (lua_State *L) { |
440 | char buff[L_tmpnam]; | 440 | char buff[L_tmpnam]; |
441 | if (tmpnam(buff) != buff) | 441 | if (tmpnam(buff) != buff) |
442 | return luaL_verror(L, "unable to generate a unique filename"); | 442 | return luaL_error(L, "unable to generate a unique filename"); |
443 | lua_pushstring(L, buff); | 443 | lua_pushstring(L, buff); |
444 | return 1; | 444 | return 1; |
445 | } | 445 | } |
@@ -480,7 +480,7 @@ static int getfield (lua_State *L, const char *key, int d) { | |||
480 | res = (int)(lua_tonumber(L, -1)); | 480 | res = (int)(lua_tonumber(L, -1)); |
481 | else { | 481 | else { |
482 | if (d == -2) | 482 | if (d == -2) |
483 | return luaL_verror(L, "field `%s' missing in date table", key); | 483 | return luaL_error(L, "field `%s' missing in date table", key); |
484 | res = d; | 484 | res = d; |
485 | } | 485 | } |
486 | lua_pop(L, 1); | 486 | lua_pop(L, 1); |
@@ -519,7 +519,7 @@ static int io_date (lua_State *L) { | |||
519 | if (strftime(b, sizeof(b), s, stm)) | 519 | if (strftime(b, sizeof(b), s, stm)) |
520 | lua_pushstring(L, b); | 520 | lua_pushstring(L, b); |
521 | else | 521 | else |
522 | return luaL_verror(L, "invalid `date' format"); | 522 | return luaL_error(L, "invalid `date' format"); |
523 | } | 523 | } |
524 | return 1; | 524 | return 1; |
525 | } | 525 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmathlib.c,v 1.45 2002/05/06 19:05:10 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.46 2002/06/05 17:24:04 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: return luaL_verror(L, "wrong number of arguments"); | 190 | default: return luaL_error(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.83 2002/06/05 17:24:04 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.84 2002/06/13 13:44:50 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 | return luaL_verror(ms->L, "invalid capture index"); | 173 | return luaL_error(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 | return luaL_verror(ms->L, "invalid pattern capture"); | 182 | return luaL_error(ms->L, "invalid pattern capture"); |
183 | } | 183 | } |
184 | 184 | ||
185 | 185 | ||
@@ -187,13 +187,13 @@ static const char *luaI_classend (MatchState *ms, const char *p) { | |||
187 | switch (*p++) { | 187 | switch (*p++) { |
188 | case ESC: | 188 | case ESC: |
189 | if (*p == '\0') | 189 | if (*p == '\0') |
190 | luaL_verror(ms->L, "malformed pattern (ends with `%')"); | 190 | luaL_error(ms->L, "malformed pattern (ends with `%')"); |
191 | return p+1; | 191 | return p+1; |
192 | case '[': | 192 | case '[': |
193 | if (*p == '^') p++; | 193 | if (*p == '^') p++; |
194 | do { /* look for a `]' */ | 194 | do { /* look for a `]' */ |
195 | if (*p == '\0') | 195 | if (*p == '\0') |
196 | luaL_verror(ms->L, "malformed pattern (missing `]')"); | 196 | luaL_error(ms->L, "malformed pattern (missing `]')"); |
197 | if (*(p++) == ESC && *p != '\0') | 197 | if (*(p++) == ESC && *p != '\0') |
198 | p++; /* skip escapes (e.g. `%]') */ | 198 | p++; /* skip escapes (e.g. `%]') */ |
199 | } while (*p != ']'); | 199 | } while (*p != ']'); |
@@ -266,7 +266,7 @@ static const char *match (MatchState *ms, const char *s, const char *p); | |||
266 | static const char *matchbalance (MatchState *ms, const char *s, | 266 | static const char *matchbalance (MatchState *ms, const char *s, |
267 | const char *p) { | 267 | const char *p) { |
268 | if (*p == 0 || *(p+1) == 0) | 268 | if (*p == 0 || *(p+1) == 0) |
269 | luaL_verror(ms->L, "unbalanced pattern"); | 269 | luaL_error(ms->L, "unbalanced pattern"); |
270 | if (*s != *p) return NULL; | 270 | if (*s != *p) return NULL; |
271 | else { | 271 | else { |
272 | int b = *p; | 272 | int b = *p; |
@@ -315,7 +315,7 @@ static const char *start_capture (MatchState *ms, const char *s, | |||
315 | const char *p, int what) { | 315 | const char *p, int what) { |
316 | const char *res; | 316 | const char *res; |
317 | int level = ms->level; | 317 | int level = ms->level; |
318 | if (level >= MAX_CAPTURES) luaL_verror(ms->L, "too many captures"); | 318 | if (level >= MAX_CAPTURES) luaL_error(ms->L, "too many captures"); |
319 | ms->capture[level].init = s; | 319 | ms->capture[level].init = s; |
320 | ms->capture[level].len = what; | 320 | ms->capture[level].len = what; |
321 | ms->level = level+1; | 321 | ms->level = level+1; |
@@ -425,7 +425,7 @@ static const char *lmemfind (const char *s1, size_t l1, | |||
425 | 425 | ||
426 | static void push_onecapture (MatchState *ms, int i) { | 426 | static void push_onecapture (MatchState *ms, int i) { |
427 | int l = ms->capture[i].len; | 427 | int l = ms->capture[i].len; |
428 | if (l == CAP_UNFINISHED) luaL_verror(ms->L, "unfinished capture"); | 428 | if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture"); |
429 | if (l == CAP_POSITION) | 429 | if (l == CAP_POSITION) |
430 | lua_pushnumber(ms->L, ms->capture[i].init - ms->src_init + 1); | 430 | lua_pushnumber(ms->L, ms->capture[i].init - ms->src_init + 1); |
431 | else | 431 | else |
@@ -635,9 +635,9 @@ static const char *scanformat (lua_State *L, const char *strfrmt, | |||
635 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ | 635 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ |
636 | } | 636 | } |
637 | if (isdigit(uchar(*p))) | 637 | if (isdigit(uchar(*p))) |
638 | luaL_verror(L, "invalid format (width or precision too long)"); | 638 | luaL_error(L, "invalid format (width or precision too long)"); |
639 | if (p-strfrmt+2 > MAX_FORMAT) /* +2 to include `%' and the specifier */ | 639 | if (p-strfrmt+2 > MAX_FORMAT) /* +2 to include `%' and the specifier */ |
640 | luaL_verror(L, "invalid format (too long)"); | 640 | luaL_error(L, "invalid format (too long)"); |
641 | form[0] = '%'; | 641 | form[0] = '%'; |
642 | strncpy(form+1, strfrmt, p-strfrmt+1); | 642 | strncpy(form+1, strfrmt, p-strfrmt+1); |
643 | form[p-strfrmt+2] = 0; | 643 | form[p-strfrmt+2] = 0; |
@@ -662,7 +662,7 @@ static int str_format (lua_State *L) { | |||
662 | char buff[MAX_ITEM]; /* to store the formatted item */ | 662 | char buff[MAX_ITEM]; /* to store the formatted item */ |
663 | int hasprecision = 0; | 663 | int hasprecision = 0; |
664 | if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$') | 664 | if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$') |
665 | return luaL_verror(L, "obsolete `format' option (d$)"); | 665 | return luaL_error(L, "obsolete `format' option (d$)"); |
666 | arg++; | 666 | arg++; |
667 | strfrmt = scanformat(L, strfrmt, form, &hasprecision); | 667 | strfrmt = scanformat(L, strfrmt, form, &hasprecision); |
668 | switch (*strfrmt++) { | 668 | switch (*strfrmt++) { |
@@ -695,7 +695,7 @@ static int str_format (lua_State *L) { | |||
695 | } | 695 | } |
696 | } | 696 | } |
697 | default: /* also treat cases `pnLlh' */ | 697 | default: /* also treat cases `pnLlh' */ |
698 | return luaL_verror(L, "invalid option in `format'"); | 698 | return luaL_error(L, "invalid option in `format'"); |
699 | } | 699 | } |
700 | luaL_addlstring(&b, buff, strlen(buff)); | 700 | luaL_addlstring(&b, buff, strlen(buff)); |
701 | } | 701 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltablib.c,v 1.5 2002/06/05 17:24:04 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.6 2002/06/13 13:44:50 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) luaL_verror(L, "invalid order function for sorting"); | 174 | if (i>u) luaL_error(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) luaL_verror(L, "invalid order function for sorting"); | 179 | if (j<l) luaL_error(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) { |