From: Sam Thorogood Date: Wed, 13 Jul 2011 17:15:00 +0000 (-0700) Subject: exp/regexp/syntax: add Prog.NumCap X-Git-Tag: weekly.2011-07-19~88 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e3a773479dd59e4722108377078c2c8404e9234c;p=gostls13.git exp/regexp/syntax: add Prog.NumCap R=rsc, r CC=golang-dev https://golang.org/cl/4662083 --- diff --git a/src/pkg/exp/regexp/syntax/compile.go b/src/pkg/exp/regexp/syntax/compile.go index ec9556fded..97f94de338 100644 --- a/src/pkg/exp/regexp/syntax/compile.go +++ b/src/pkg/exp/regexp/syntax/compile.go @@ -185,6 +185,10 @@ func (c *compiler) cap(arg uint32) frag { f := c.inst(InstCapture) f.out = patchList(f.i << 1) c.p.Inst[f.i].Arg = arg + + if c.p.NumCap < int(arg)+1 { + c.p.NumCap = int(arg) + 1 + } return f } diff --git a/src/pkg/exp/regexp/syntax/prog.go b/src/pkg/exp/regexp/syntax/prog.go index 6eeb3da0ce..4af4a32e16 100644 --- a/src/pkg/exp/regexp/syntax/prog.go +++ b/src/pkg/exp/regexp/syntax/prog.go @@ -10,8 +10,9 @@ import ( // A Prog is a compiled regular expression program. type Prog struct { - Inst []Inst - Start int // index of start instruction + Inst []Inst + Start int // index of start instruction + NumCap int // number of InstCapture insts in re } // An InstOp is an instruction opcode.