1
0
mirror of https://github.com/golang/go synced 2024-11-21 22:14:41 -07:00

template: fix deadlock.

No need for lexInsideAction to loop.
Fixes #2217.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4963054
This commit is contained in:
Rob Pike 2011-09-02 11:00:46 +10:00
parent 5edeef214d
commit 2cf66c1d94
2 changed files with 58 additions and 46 deletions

View File

@ -278,7 +278,6 @@ func lexInsideAction(l *lexer) stateFn {
// Either number, quoted string, or identifier.
// Spaces separate and are ignored.
// Pipe symbols separate and are emitted.
for {
if strings.HasPrefix(l.input[l.pos:], rightDelim) {
return lexRightDelim
}
@ -323,8 +322,7 @@ func lexInsideAction(l *lexer) stateFn {
default:
return l.errorf("unrecognized character in action: %#U", r)
}
}
return nil
return lexInsideAction
}
// lexIdentifier scans an alphanumeric or field.

View File

@ -184,6 +184,20 @@ var lexTests = []lexTest{
tLeft,
{itemError, `bad number syntax: "3k"`},
}},
// Fixed bugs
// Many elements in an action blew the lookahead until
// we made lexInsideAction not loop.
{"long pipeline deadlock", "{{|||||}}", []item{
tLeft,
tPipe,
tPipe,
tPipe,
tPipe,
tPipe,
tRight,
tEOF,
}},
}
// collect gathers the emitted items into a slice.