summaryrefslogtreecommitdiffstats
path: root/regex.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-06-29 01:58:02 -0500
committerKaz Kylheku <kaz@kylheku.com>2024-06-29 01:58:02 -0500
commitd05ca75be66d011778e6190ea5de6bc2211603d1 (patch)
tree04a228cd1fe945f7044e80c931efa26ae0477346 /regex.c
parent6de5cc7e27fd19b41a14332c0461acc22db46b3d (diff)
downloadtxr-d05ca75be66d011778e6190ea5de6bc2211603d1.tar.gz
txr-d05ca75be66d011778e6190ea5de6bc2211603d1.tar.bz2
txr-d05ca75be66d011778e6190ea5de6bc2211603d1.zip
txr: real solution for spurious retention problem.
We take advantage of the nested, recursive nature of the pattern language. Whenever a new data context is initiated, we indicate that that context is current, in a dynamic variable. Then, in the various data scanning directives (scan, collect, repeat, gather), when performing the c->data = rest(c->data) step to march down the lazy list, check whether the context c is the current one. If that is the case, we know that backtracking is not possible, and so we can safely pass the c->data cons to the rcyc_cons function for recycling. Otherwise we do the c->data = rest(c->data) only. It's already the case that whenever backtracking is necessary, a new, disposable context is allocated which is thrown away on failure. Those contexts are never registered as current, and so never match. * match.c (match_files_ctx): Introduce a tag name to the structure, struct match_files_ctx. Remove the volatile qualifier from the data member, and put it back int the original order. New member up for linking these structures into a stack. (mf_current): New static variable. (step_data): New static function. This is where we do the retention-resistant step of c->data. (v_skip, v_fuzz, v_gather, v_collect, match_files_byref): Use step_data function rather than c->data = rest(c->data). (v_next_impl, extract): Register the new scanning context as current by assigning it to mf_current, taking care to save and restore the previous value, even if the matching is abandoned by an exception.
Diffstat (limited to 'regex.c')
0 files changed, 0 insertions, 0 deletions