aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-05-06 16:05:10 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-05-06 16:05:10 -0300
commit71144e3ff0cb81bd9b8bb56d94dc76074c638c64 (patch)
tree8098675276d0640684898d4302ea98ae91e2c430 /lstrlib.c
parent0dbf0c5953a3d72deebc7e41840a0e73b46de8bc (diff)
downloadlua-71144e3ff0cb81bd9b8bb56d94dc76074c638c64.tar.gz
lua-71144e3ff0cb81bd9b8bb56d94dc76074c638c64.tar.bz2
lua-71144e3ff0cb81bd9b8bb56d94dc76074c638c64.zip
errors `return' int, to avoid warnings
+ home-made `sprintf' (first version)
Diffstat (limited to 'lstrlib.c')
-rw-r--r--lstrlib.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lstrlib.c b/lstrlib.c
index b308b78e..8a3cd686 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.80 2002/04/02 20:41:59 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.81 2002/05/02 17:12:27 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 luaL_verror(ms->L, "invalid capture index"); 173 return luaL_verror(ms->L, "invalid capture index");
174 return l; 174 return l;
175} 175}
176 176
@@ -179,8 +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 luaL_verror(ms->L, "invalid pattern capture"); 182 return luaL_verror(ms->L, "invalid pattern capture");
183 return 0; /* to avoid warnings */
184} 183}
185 184
186 185
@@ -663,7 +662,7 @@ static int str_format (lua_State *L) {
663 char buff[MAX_ITEM]; /* to store the formatted item */ 662 char buff[MAX_ITEM]; /* to store the formatted item */
664 int hasprecision = 0; 663 int hasprecision = 0;
665 if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$') 664 if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$')
666 luaL_verror(L, "obsolete `format' option (d$)"); 665 return luaL_verror(L, "obsolete `format' option (d$)");
667 arg++; 666 arg++;
668 strfrmt = scanformat(L, strfrmt, form, &hasprecision); 667 strfrmt = scanformat(L, strfrmt, form, &hasprecision);
669 switch (*strfrmt++) { 668 switch (*strfrmt++) {
@@ -696,7 +695,7 @@ static int str_format (lua_State *L) {
696 } 695 }
697 } 696 }
698 default: /* also treat cases `pnLlh' */ 697 default: /* also treat cases `pnLlh' */
699 luaL_verror(L, "invalid option in `format'"); 698 return luaL_verror(L, "invalid option in `format'");
700 } 699 }
701 luaL_addlstring(&b, buff, strlen(buff)); 700 luaL_addlstring(&b, buff, strlen(buff));
702 } 701 }