From d97fe6ed31d4b274c88c996b0c06da597a455149 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 27 Feb 2019 12:42:16 -0300 Subject: Fixed bug when resizing capture list Fixed the bug reported in http://lua-users.org/lists/lua-l/2018-11/msg00080.html The field 's' of the open group of captures inside a run-time capture was being reused by the open group of the results of the run-time capture, even though that open-group entry was being removed from the list and then added again. --- lpcap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lpcap.c') diff --git a/lpcap.c b/lpcap.c index 1c2af0b..b332fde 100644 --- a/lpcap.c +++ b/lpcap.c @@ -271,15 +271,15 @@ int finddyncap (Capture *cap, Capture *last) { /* -** Calls a runtime capture. Returns number of captures removed by -** the call, including the initial Cgroup. (Captures to be added are -** on the Lua stack.) +** Calls a runtime capture. Returns number of captures "removed" by the +** call, that is, those inside the group capture. Captures to be added +** are on the Lua stack. */ int runtimecap (CapState *cs, Capture *close, const char *s, int *rem) { int n, id; lua_State *L = cs->L; int otop = lua_gettop(L); - Capture *open = findopen(close); + Capture *open = findopen(close); /* get open group capture */ assert(captype(open) == Cgroup); id = finddyncap(open, close); /* get first dynamic capture argument */ close->kind = Cclose; /* closes the group */ @@ -299,7 +299,7 @@ int runtimecap (CapState *cs, Capture *close, const char *s, int *rem) { } else *rem = 0; /* no dynamic captures removed */ - return close - open; /* number of captures of all kinds removed */ + return close - open - 1; /* number of captures to be removed */ } -- cgit v1.2.3-55-g6feb