Commit ce5c1cf0 authored by Rob Pike's avatar Rob Pike

fmt: fix bug in UnreadRune: must clear memory of previous

rune if input implements UnreadRune; otherwise the lookahead
will lie.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4548082
parent 4e9e9250
......@@ -226,20 +226,12 @@ func (s *ss) mustReadRune() (rune int) {
}
func (s *ss) UnreadRune() os.Error {
// Don't use strings.Reader.UnreadRune for now - appears to cause a problem.
// TODO(r, gri): Fix this and remove code between --- lines!
// ---
if _, ok := s.rr.(*strings.Reader); ok {
s.peekRune = s.prevRune
s.count--
return nil
}
// ---
if u, ok := s.rr.(runeUnreader); ok {
u.UnreadRune()
} else {
s.peekRune = s.prevRune
}
s.prevRune = -1
s.count--
return nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment