aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bugs27
-rw-r--r--lstrlib.c9
2 files changed, 31 insertions, 5 deletions
diff --git a/bugs b/bugs
index 38d295ae..355870e2 100644
--- a/bugs
+++ b/bugs
@@ -3575,6 +3575,33 @@ patch = [[
3575} 3575}
3576 3576
3577 3577
3578Bug{
3579what = [['gmatch' iterator fails when called from a coroutine different
3580from the one that created it]],
3581report = [[Nagaev Boris, 2016/03/18]],
3582since = [[5.3.2]],
3583fix = nil,
3584example = [[
3585local f = string.gmatch("1 2 3 4 5", "%d+")
3586print(f()) --> 1
3587co = coroutine.wrap(f)
3588print(co()) --> ??? (should be 2)
3589]],
3590patch = [[
3591--- lstrlib.c 2016/02/25 19:42:55 1.240
3592+++ lstrlib.c 2016/03/21 17:27:07
3593@@ -688,14 +688,13 @@
3594 static int gmatch_aux (lua_State *L) {
3595 GMatchState *gm = (GMatchState *)lua_touserdata(L, lua_upvalueindex(3));
3596 const char *src;
3597+ gm->ms.L = L;
3598 for (src = gm->src; src <= gm->ms.src_end; src++) {
3599 const char *e;
3600 reprepstate(&gm->ms);
3601]]
3602}
3603
3604
3578--[=[ 3605--[=[
3579Bug{ 3606Bug{
3580what = [[ ]], 3607what = [[ ]],
diff --git a/lstrlib.c b/lstrlib.c
index 2f9dbf0f..c07cdbb7 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstrlib.c,v 1.239 2015/11/25 16:28:17 roberto Exp roberto $ 2** $Id: lstrlib.c,v 1.240 2016/02/25 19:42:55 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*/
@@ -688,14 +688,13 @@ typedef struct GMatchState {
688static int gmatch_aux (lua_State *L) { 688static int gmatch_aux (lua_State *L) {
689 GMatchState *gm = (GMatchState *)lua_touserdata(L, lua_upvalueindex(3)); 689 GMatchState *gm = (GMatchState *)lua_touserdata(L, lua_upvalueindex(3));
690 const char *src; 690 const char *src;
691 gm->ms.L = L;
691 for (src = gm->src; src <= gm->ms.src_end; src++) { 692 for (src = gm->src; src <= gm->ms.src_end; src++) {
692 const char *e; 693 const char *e;
693 reprepstate(&gm->ms); 694 reprepstate(&gm->ms);
694 if ((e = match(&gm->ms, src, gm->p)) != NULL) { 695 if ((e = match(&gm->ms, src, gm->p)) != NULL) {
695 if (e == src) /* empty match? */ 696 /* in empty matches, advance at least one position */
696 gm->src =src + 1; /* go at least one position */ 697 gm->src = (e == src) ? src + 1 : e;
697 else
698 gm->src = e;
699 return push_captures(&gm->ms, src, e); 698 return push_captures(&gm->ms, src, e);
700 } 699 }
701 } 700 }