Commit b790ae2e authored by Robert Griesemer's avatar Robert Griesemer

go/printer, gofmt: fix formatting of expression lists (missing blank)

This appears to have been a long-standing formatting bug.
The test cases has misformatted golden files.

Applied gofmt -w src misc .

Fixes #1839.

R=iant
CC=golang-dev
https://golang.org/cl/4515113
parent 2f5a77cd
...@@ -73,7 +73,7 @@ func dashStatus(meth, cmd string, args param) os.Error { ...@@ -73,7 +73,7 @@ func dashStatus(meth, cmd string, args param) os.Error {
// todo returns the next hash to build. // todo returns the next hash to build.
func (b *Builder) todo() (rev string, err os.Error) { func (b *Builder) todo() (rev string, err os.Error) {
var resp []struct{ var resp []struct {
Hash string Hash string
} }
if err = dash("GET", "todo", &resp, param{"builder": b.name}); err != nil { if err = dash("GET", "todo", &resp, param{"builder": b.name}); err != nil {
......
...@@ -434,8 +434,8 @@ func commitPoll(key string) { ...@@ -434,8 +434,8 @@ func commitPoll(key string) {
data, _, err := runLog(nil, "", goroot, "hg", "log", data, _, err := runLog(nil, "", goroot, "hg", "log",
"--encoding=utf-8", "--encoding=utf-8",
"--limit=" + strconv.Itoa(N), "--limit="+strconv.Itoa(N),
"--template=" + xmlLogTemplate, "--template="+xmlLogTemplate,
) )
if err != nil { if err != nil {
log.Printf("hg log: %v", err) log.Printf("hg log: %v", err)
...@@ -445,7 +445,7 @@ func commitPoll(key string) { ...@@ -445,7 +445,7 @@ func commitPoll(key string) {
var logStruct struct { var logStruct struct {
Log []HgLog Log []HgLog
} }
err = xml.Unmarshal(strings.NewReader("<top>" + data + "</top>"), &logStruct) err = xml.Unmarshal(strings.NewReader("<top>"+data+"</top>"), &logStruct)
if err != nil { if err != nil {
log.Printf("unmarshal hg log: %v", err) log.Printf("unmarshal hg log: %v", err)
return return
......
...@@ -215,12 +215,13 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp ...@@ -215,12 +215,13 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp
} }
if i > 0 { if i > 0 {
if mode&commaSep != 0 { switch {
case mode&commaSep != 0:
p.print(token.COMMA) p.print(token.COMMA)
} case mode&periodSep != 0:
if mode&periodSep != 0 {
p.print(token.PERIOD) p.print(token.PERIOD)
} }
needsBlank := mode&periodSep == 0 // period-separated list elements don't need a blank
if prevLine < line && prevLine > 0 && line > 0 { if prevLine < line && prevLine > 0 && line > 0 {
// lines are broken using newlines so comments remain aligned // lines are broken using newlines so comments remain aligned
// unless forceFF is set or there are multiple expressions on // unless forceFF is set or there are multiple expressions on
...@@ -229,11 +230,12 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp ...@@ -229,11 +230,12 @@ func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exp
ws = ignore ws = ignore
*multiLine = true *multiLine = true
prevBreak = i prevBreak = i
needsBlank = false // we got a line break instead
} }
} else if mode&periodSep == 0 { }
if needsBlank {
p.print(blank) p.print(blank)
} }
// period-separated list elements don't need a blank
} }
if isPair && size > 0 && len(list) > 1 { if isPair && size > 0 && len(list) > 1 {
......
...@@ -644,7 +644,7 @@ func _() { ...@@ -644,7 +644,7 @@ func _() {
func f() { func f() {
// os.Open parameters should remain on two lines // os.Open parameters should remain on two lines
if writer, err = os.Open(outfile, s.O_WRONLY|os.O_CREATE| if writer, err = os.Open(outfile, s.O_WRONLY|os.O_CREATE|
os.O_TRUNC,0666); err != nil { os.O_TRUNC, 0666); err != nil {
log.Fatal(err) log.Fatal(err)
} }
} }
...@@ -644,7 +644,7 @@ func _() { ...@@ -644,7 +644,7 @@ func _() {
func f() { func f() {
// os.Open parameters should remain on two lines // os.Open parameters should remain on two lines
if writer, err = os.Open(outfile, s.O_WRONLY|os.O_CREATE| if writer, err = os.Open(outfile, s.O_WRONLY|os.O_CREATE|
os.O_TRUNC,0666); err != nil { os.O_TRUNC, 0666); err != nil {
log.Fatal(err) log.Fatal(err)
} }
} }
...@@ -624,7 +624,7 @@ func TestServerConsumesRequestBody(t *testing.T) { ...@@ -624,7 +624,7 @@ func TestServerConsumesRequestBody(t *testing.T) {
"POST / HTTP/1.1\r\n"+ "POST / HTTP/1.1\r\n"+
"Host: test\r\n"+ "Host: test\r\n"+
"Content-Length: %d\r\n"+ "Content-Length: %d\r\n"+
"\r\n",len(body)))) "\r\n", len(body))))
conn.readBuf.Write([]byte(body)) conn.readBuf.Write([]byte(body))
done := make(chan bool) done := make(chan bool)
......
...@@ -315,7 +315,7 @@ foo: bar ...@@ -315,7 +315,7 @@ foo: bar
--MyBoundary-- --MyBoundary--
`,"\n", "\r\n", -1) `, "\n", "\r\n", -1)
r := NewReader(strings.NewReader(testBody), "MyBoundary") r := NewReader(strings.NewReader(testBody), "MyBoundary")
part, err := r.NextPart() part, err := r.NextPart()
if err != nil { if err != nil {
......
...@@ -56,6 +56,6 @@ func TestLookup(t *testing.T) { ...@@ -56,6 +56,6 @@ func TestLookup(t *testing.T) {
if !reflect.DeepEqual(u, un) { if !reflect.DeepEqual(u, un) {
t.Errorf("Lookup by userid vs. name didn't match\n"+ t.Errorf("Lookup by userid vs. name didn't match\n"+
"LookupId(%d): %#v\n"+ "LookupId(%d): %#v\n"+
"Lookup(%q): %#v\n",uid, u, u.Username, un) "Lookup(%q): %#v\n", uid, u, u.Username, un)
} }
} }
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