* fixes #19104; peg Incorrect captures [backport:1.6] * add tests Co-authored-by: khchen <khchen@gmail.com>
This commit is contained in:
parent
79afee868d
commit
2b80ff2374
2 changed files with 8 additions and 1 deletions
|
|
@ -838,10 +838,13 @@ template matchOrParse(mopProc: untyped) =
|
|||
var idx = c.ml # reserve a slot for the subpattern
|
||||
result = mopProc(s, p.sons[0], start, c)
|
||||
if result >= 0:
|
||||
inc(c.ml)
|
||||
if idx < MaxSubpatterns:
|
||||
if idx != c.ml:
|
||||
for i in countdown(c.ml, idx):
|
||||
c.matches[i+1] = c.matches[i]
|
||||
c.matches[idx] = (start, start+result-1)
|
||||
#else: silently ignore the capture
|
||||
inc(c.ml)
|
||||
leave(pkCapture, s, p, start, result)
|
||||
of pkBackRef:
|
||||
enter(pkBackRef, s, p, start)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue