diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-01-08 14:22:32 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-01-08 14:22:32 -0200 |
commit | 264659bd53e92969a1e17d65c0266597cde24b5d (patch) | |
tree | 6aba62d2b6ac2a46dc064ea7193c8134200a7d57 /lvm.c | |
parent | 4ace93ca6502dd1da38d5c06fa099d229e791ba8 (diff) | |
download | lua-264659bd53e92969a1e17d65c0266597cde24b5d.tar.gz lua-264659bd53e92969a1e17d65c0266597cde24b5d.tar.bz2 lua-264659bd53e92969a1e17d65c0266597cde24b5d.zip |
Optional 'init' argument to 'string.gmatch'
The function 'string.gmatch' now has an optional 'init' argument,
similar to 'string.find' and 'string.match'. Moreover, there was
some reorganization in the manipulation of indices in the string
library.
This commit also includes small janitorial work in the manual
and in comments in the interpreter loop.
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -991,7 +991,8 @@ void luaV_finishOp (lua_State *L) { | |||
991 | 991 | ||
992 | /* | 992 | /* |
993 | ** Protect code that will finish the loop (returns) or can only raise | 993 | ** Protect code that will finish the loop (returns) or can only raise |
994 | ** errors. | 994 | ** errors. (That is, it will not return to the interpreter main loop |
995 | ** after changing the stack or hooks.) | ||
995 | */ | 996 | */ |
996 | #define halfProtect(exp) (savepc(L), (exp)) | 997 | #define halfProtect(exp) (savepc(L), (exp)) |
997 | 998 | ||
@@ -1607,7 +1608,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1607 | L->top = ra; | 1608 | L->top = ra; |
1608 | halfProtect(luaD_poscall(L, ci, 0)); /* no hurry... */ | 1609 | halfProtect(luaD_poscall(L, ci, 0)); /* no hurry... */ |
1609 | } | 1610 | } |
1610 | else { | 1611 | else { /* do the 'poscall' here */ |
1611 | int nres = ci->nresults; | 1612 | int nres = ci->nresults; |
1612 | L->ci = ci->previous; /* back to caller */ | 1613 | L->ci = ci->previous; /* back to caller */ |
1613 | L->top = base - 1; | 1614 | L->top = base - 1; |
@@ -1621,7 +1622,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1621 | L->top = ra + 1; | 1622 | L->top = ra + 1; |
1622 | halfProtect(luaD_poscall(L, ci, 1)); /* no hurry... */ | 1623 | halfProtect(luaD_poscall(L, ci, 1)); /* no hurry... */ |
1623 | } | 1624 | } |
1624 | else { | 1625 | else { /* do the 'poscall' here */ |
1625 | int nres = ci->nresults; | 1626 | int nres = ci->nresults; |
1626 | L->ci = ci->previous; /* back to caller */ | 1627 | L->ci = ci->previous; /* back to caller */ |
1627 | if (nres == 0) | 1628 | if (nres == 0) |
@@ -1652,8 +1653,8 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1652 | lua_Integer ilimit, initv; | 1653 | lua_Integer ilimit, initv; |
1653 | int stopnow; | 1654 | int stopnow; |
1654 | if (unlikely(!forlimit(plimit, &ilimit, 1, &stopnow))) { | 1655 | if (unlikely(!forlimit(plimit, &ilimit, 1, &stopnow))) { |
1655 | savestate(L, ci); /* for the error message */ | 1656 | savestate(L, ci); /* for the error message */ |
1656 | luaG_forerror(L, plimit, "limit"); | 1657 | luaG_forerror(L, plimit, "limit"); |
1657 | } | 1658 | } |
1658 | initv = (stopnow ? 0 : ivalue(init)); | 1659 | initv = (stopnow ? 0 : ivalue(init)); |
1659 | setivalue(plimit, ilimit); | 1660 | setivalue(plimit, ilimit); |
@@ -1717,8 +1718,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1717 | vmbreak; | 1718 | vmbreak; |
1718 | } | 1719 | } |
1719 | vmcase(OP_TFORPREP) { | 1720 | vmcase(OP_TFORPREP) { |
1720 | /* is 'toclose' not nil? */ | 1721 | if (!ttisnil(s2v(ra + 3))) { /* is 'toclose' not nil? */ |
1721 | if (!ttisnil(s2v(ra + 3))) { | ||
1722 | /* create to-be-closed upvalue for it */ | 1722 | /* create to-be-closed upvalue for it */ |
1723 | halfProtect(luaF_newtbcupval(L, ra + 3)); | 1723 | halfProtect(luaF_newtbcupval(L, ra + 3)); |
1724 | } | 1724 | } |