aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-06-18 12:16:18 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-06-18 12:16:18 -0300
commitd8678edddc98beab8eb78e63e698191a9ffd39b8 (patch)
treefa8b5e3595f0caa11fb8ee5bfc3412e76dbef230 /lstrlib.c
parente812aa200234629d89351b6653d6ae737478ccd8 (diff)
downloadlua-d8678edddc98beab8eb78e63e698191a9ffd39b8.tar.gz
lua-d8678edddc98beab8eb78e63e698191a9ffd39b8.tar.bz2
lua-d8678edddc98beab8eb78e63e698191a9ffd39b8.zip
luaL_verror -> luaL_error
Diffstat (limited to 'lstrlib.c')
-rw-r--r--lstrlib.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lstrlib.c b/lstrlib.c
index 196a0ce4..a5a281c0 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -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 {
170static int check_capture (MatchState *ms, int l) { 170static 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);
266static const char *matchbalance (MatchState *ms, const char *s, 266static 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
426static void push_onecapture (MatchState *ms, int i) { 426static 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 }