mirror of
https://github.com/golang/go
synced 2024-11-22 05:04:40 -07:00
Fix bug in godoc tab conversion filter:
tabs after an empty line where not converted. Also, made it more robust in the presence of (unexpected) ' ' and '\v' chars in indentation mode. R=r CC=golang-dev https://golang.org/cl/181085
This commit is contained in:
parent
f0fcb2d59f
commit
2aefb8d930
@ -471,8 +471,8 @@ type tconv struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (p *tconv) writeIndent(n int) (err os.Error) {
|
func (p *tconv) writeIndent() (err os.Error) {
|
||||||
i := n * *tabwidth
|
i := p.indent
|
||||||
for i > len(spaces) {
|
for i > len(spaces) {
|
||||||
i -= len(spaces)
|
i -= len(spaces)
|
||||||
if _, err = p.output.Write(spaces); err != nil {
|
if _, err = p.output.Write(spaces); err != nil {
|
||||||
@ -490,12 +490,20 @@ func (p *tconv) Write(data []byte) (n int, err os.Error) {
|
|||||||
for n, b = range data {
|
for n, b = range data {
|
||||||
switch p.state {
|
switch p.state {
|
||||||
case indenting:
|
case indenting:
|
||||||
if b == '\t' {
|
switch b {
|
||||||
|
case '\t', '\v':
|
||||||
|
p.indent += *tabwidth
|
||||||
|
case '\n':
|
||||||
|
p.indent = 0
|
||||||
|
if _, err = p.output.Write(data[n : n+1]); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case ' ':
|
||||||
p.indent++
|
p.indent++
|
||||||
} else {
|
default:
|
||||||
p.state = collecting
|
p.state = collecting
|
||||||
pos = n
|
pos = n
|
||||||
if err = p.writeIndent(p.indent); err != nil {
|
if err = p.writeIndent(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user