Commit 2cf66c1d authored by Rob Pike's avatar Rob Pike

template: fix deadlock.

No need for lexInsideAction to loop.
Fixes #2217.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4963054
parent 5edeef21
...@@ -278,7 +278,6 @@ func lexInsideAction(l *lexer) stateFn { ...@@ -278,7 +278,6 @@ func lexInsideAction(l *lexer) stateFn {
// Either number, quoted string, or identifier. // Either number, quoted string, or identifier.
// Spaces separate and are ignored. // Spaces separate and are ignored.
// Pipe symbols separate and are emitted. // Pipe symbols separate and are emitted.
for {
if strings.HasPrefix(l.input[l.pos:], rightDelim) { if strings.HasPrefix(l.input[l.pos:], rightDelim) {
return lexRightDelim return lexRightDelim
} }
...@@ -323,8 +322,7 @@ func lexInsideAction(l *lexer) stateFn { ...@@ -323,8 +322,7 @@ func lexInsideAction(l *lexer) stateFn {
default: default:
return l.errorf("unrecognized character in action: %#U", r) return l.errorf("unrecognized character in action: %#U", r)
} }
} return lexInsideAction
return nil
} }
// lexIdentifier scans an alphanumeric or field. // lexIdentifier scans an alphanumeric or field.
......
...@@ -184,6 +184,20 @@ var lexTests = []lexTest{ ...@@ -184,6 +184,20 @@ var lexTests = []lexTest{
tLeft, tLeft,
{itemError, `bad number syntax: "3k"`}, {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. // collect gathers the emitted items into a slice.
......
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