aboutsummaryrefslogtreecommitdiff
path: root/lpcap.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-02-27 12:42:16 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-02-27 12:42:16 -0300
commitd97fe6ed31d4b274c88c996b0c06da597a455149 (patch)
treea37297862273c9e44197026923bc4a4c3d1e16f9 /lpcap.c
parentf53caf1f863f140de1c1af51906e658c9fb7d7d6 (diff)
downloadlpeg-d97fe6ed31d4b274c88c996b0c06da597a455149.tar.gz
lpeg-d97fe6ed31d4b274c88c996b0c06da597a455149.tar.bz2
lpeg-d97fe6ed31d4b274c88c996b0c06da597a455149.zip
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.
Diffstat (limited to 'lpcap.c')
-rw-r--r--lpcap.c10
1 files changed, 5 insertions, 5 deletions
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) {
271 271
272 272
273/* 273/*
274** Calls a runtime capture. Returns number of captures removed by 274** Calls a runtime capture. Returns number of captures "removed" by the
275** the call, including the initial Cgroup. (Captures to be added are 275** call, that is, those inside the group capture. Captures to be added
276** on the Lua stack.) 276** are on the Lua stack.
277*/ 277*/
278int runtimecap (CapState *cs, Capture *close, const char *s, int *rem) { 278int runtimecap (CapState *cs, Capture *close, const char *s, int *rem) {
279 int n, id; 279 int n, id;
280 lua_State *L = cs->L; 280 lua_State *L = cs->L;
281 int otop = lua_gettop(L); 281 int otop = lua_gettop(L);
282 Capture *open = findopen(close); 282 Capture *open = findopen(close); /* get open group capture */
283 assert(captype(open) == Cgroup); 283 assert(captype(open) == Cgroup);
284 id = finddyncap(open, close); /* get first dynamic capture argument */ 284 id = finddyncap(open, close); /* get first dynamic capture argument */
285 close->kind = Cclose; /* closes the group */ 285 close->kind = Cclose; /* closes the group */
@@ -299,7 +299,7 @@ int runtimecap (CapState *cs, Capture *close, const char *s, int *rem) {
299 } 299 }
300 else 300 else
301 *rem = 0; /* no dynamic captures removed */ 301 *rem = 0; /* no dynamic captures removed */
302 return close - open; /* number of captures of all kinds removed */ 302 return close - open - 1; /* number of captures to be removed */
303} 303}
304 304
305 305