diff options
Diffstat (limited to 'src/encoding/xml/xml.go')
| -rw-r--r-- | src/encoding/xml/xml.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go index ef51252dcb..a7a02f5b57 100644 --- a/src/encoding/xml/xml.go +++ b/src/encoding/xml/xml.go @@ -216,6 +216,7 @@ type Decoder struct { ns map[string]string err error line int + linestart int64 offset int64 unmarshalDepth int } @@ -919,6 +920,7 @@ func (d *Decoder) getc() (b byte, ok bool) { } if b == '\n' { d.line++ + d.linestart = d.offset + 1 } d.offset++ return b, true @@ -931,6 +933,13 @@ func (d *Decoder) InputOffset() int64 { return d.offset } +// InputPos retuns the line of the current decoder position and the 1 based +// input position of the line. The position gives the location of the end of the +// most recently returned token. +func (d *Decoder) InputPos() (line, column int) { + return d.line, int(d.offset-d.linestart) + 1 +} + // Return saved offset. // If we did ungetc (nextByte >= 0), have to back up one. func (d *Decoder) savedOffset() int { |
