xml: new "innerxml" tag to collect inner XML

R=r
CC=golang-dev
https://golang.org/cl/971041
This commit is contained in:
Russ Cox 2010-04-21 16:27:31 -07:00
parent 57d9de3ac8
commit e7b6fe3989
3 changed files with 66 additions and 13 deletions

View file

@ -165,6 +165,7 @@ type Parser struct {
r io.ReadByter
buf bytes.Buffer
saved *bytes.Buffer
stk *stack
free *stack
needClose bool
@ -698,6 +699,9 @@ func (p *Parser) getc() (b byte, ok bool) {
if p.err != nil {
return 0, false
}
if p.saved != nil {
p.saved.WriteByte(b)
}
}
if b == '\n' {
p.line++
@ -705,6 +709,16 @@ func (p *Parser) getc() (b byte, ok bool) {
return b, true
}
// Return saved offset.
// If we did ungetc (nextByte >= 0), have to back up one.
func (p *Parser) savedOffset() int {
n := p.saved.Len()
if p.nextByte >= 0 {
n--
}
return n
}
// Must read a single byte.
// If there is no byte to read,
// set p.err to SyntaxError("unexpected EOF")