1
0
mirror of https://github.com/golang/go synced 2024-11-19 13:44:52 -07:00

exp/regexp/syntax: add Prog.NumCap

R=rsc, r
CC=golang-dev
https://golang.org/cl/4662083
This commit is contained in:
Sam Thorogood 2011-07-13 10:15:00 -07:00 committed by Russ Cox
parent 4c986d86b1
commit e3a773479d
2 changed files with 7 additions and 2 deletions

View File

@ -185,6 +185,10 @@ func (c *compiler) cap(arg uint32) frag {
f := c.inst(InstCapture) f := c.inst(InstCapture)
f.out = patchList(f.i << 1) f.out = patchList(f.i << 1)
c.p.Inst[f.i].Arg = arg c.p.Inst[f.i].Arg = arg
if c.p.NumCap < int(arg)+1 {
c.p.NumCap = int(arg) + 1
}
return f return f
} }

View File

@ -10,8 +10,9 @@ import (
// A Prog is a compiled regular expression program. // A Prog is a compiled regular expression program.
type Prog struct { type Prog struct {
Inst []Inst Inst []Inst
Start int // index of start instruction Start int // index of start instruction
NumCap int // number of InstCapture insts in re
} }
// An InstOp is an instruction opcode. // An InstOp is an instruction opcode.