]> Cypherpunks repositories - gostls13.git/commitdiff
exp/regexp/syntax: add Prog.NumCap
authorSam Thorogood <thorogood@google.com>
Wed, 13 Jul 2011 17:15:00 +0000 (10:15 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 13 Jul 2011 17:15:00 +0000 (10:15 -0700)
R=rsc, r
CC=golang-dev
https://golang.org/cl/4662083

src/pkg/exp/regexp/syntax/compile.go
src/pkg/exp/regexp/syntax/prog.go

index ec9556fded625a7b34fedb8fd834a64a8bc26089..97f94de338aacba7fd804d045d63dc0b474a408b 100644 (file)
@@ -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
 }
 
index 6eeb3da0ce4964035404a3a4b9ef0a92277f19af..4af4a32e16311945363cfd7b1711a1d069fd903a 100644 (file)
@@ -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.