aboutsummaryrefslogtreecommitdiff
path: root/lstrlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-08-16 14:58:02 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-08-16 14:58:02 -0300
commitb96b0b5abbf40cbdbed7952bf35a5a27ddf75928 (patch)
tree5d9d5463cb7d3424833abab20dd87bce1f4b240f /lstrlib.c
parentca13be9af784b7288d3a07d9b5bccb329086e885 (diff)
downloadlua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.tar.gz
lua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.tar.bz2
lua-b96b0b5abbf40cbdbed7952bf35a5a27ddf75928.zip
Added macro 'luaL_pushfail'
The macro 'luaL_pushfail' documents all places in the standard libraries that return nil to signal some kind of failure. It is defined as 'lua_pushnil'. The manual also got a notation (@fail) to document those returns. The tests were changed to be agnostic regarding whether 'fail' is 'nil' or 'false'.
Diffstat (limited to 'lstrlib.c')
-rw-r--r--lstrlib.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lstrlib.c b/lstrlib.c
index 8c9e1a83..7f4a0184 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -744,7 +744,7 @@ static int str_find_aux (lua_State *L, int find) {
744 const char *p = luaL_checklstring(L, 2, &lp); 744 const char *p = luaL_checklstring(L, 2, &lp);
745 size_t init = posrelatI(luaL_optinteger(L, 3, 1), ls) - 1; 745 size_t init = posrelatI(luaL_optinteger(L, 3, 1), ls) - 1;
746 if (init > ls) { /* start after string's end? */ 746 if (init > ls) { /* start after string's end? */
747 lua_pushnil(L); /* cannot find anything */ 747 luaL_pushfail(L); /* cannot find anything */
748 return 1; 748 return 1;
749 } 749 }
750 /* explicit request or no special characters? */ 750 /* explicit request or no special characters? */
@@ -779,7 +779,7 @@ static int str_find_aux (lua_State *L, int find) {
779 } 779 }
780 } while (s1++ < ms.src_end && !anchor); 780 } while (s1++ < ms.src_end && !anchor);
781 } 781 }
782 lua_pushnil(L); /* not found */ 782 luaL_pushfail(L); /* not found */
783 return 1; 783 return 1;
784} 784}
785 785