diff --git a/core/print.go b/core/print.go index c4b5fda1f..4dff98cfb 100644 --- a/core/print.go +++ b/core/print.go @@ -296,7 +296,7 @@ func (p *printer) expr(v Expr, outerPrec int) { // This preserves the specific escaping choices that // BUILD authors have made, and it also works around // b/7272572. - if strings.HasPrefix(v.Token, `"`) { + if strings.HasPrefix(v.Token, `'`) { s, triple, err := unquote(v.Token) if s == v.Value && triple == v.TripleQuote && err == nil { p.printf("%s", v.Token) @@ -379,7 +379,7 @@ func (p *printer) expr(v Expr, outerPrec int) { if v.LineBreak { p.margin = p.indent() if v.Op == "=" { - p.margin += 4 + p.margin += 2 } } @@ -501,7 +501,7 @@ func (p *printer) seq(brack string, list []Expr, end *End, mode seqMode, forceCo default: // Multi-line form. - p.margin += 4 + p.margin += 2 for i, x := range list { // If we are about to break the line before the first // element and there are trailing end-of-line comments @@ -525,7 +525,7 @@ func (p *printer) seq(brack string, list []Expr, end *End, mode seqMode, forceCo p.newline() p.printf("%s", strings.TrimSpace(com.Token)) } - p.margin -= 4 + p.margin -= 2 p.newline() } p.depth-- @@ -563,7 +563,7 @@ func (p *printer) listFor(v *ListForExpr) { if multiLine { if v.Brack != "" { - p.margin += 4 + p.margin += 2 } p.newline() } @@ -595,7 +595,7 @@ func (p *printer) listFor(v *ListForExpr) { p.printf("%s", strings.TrimSpace(com.Token)) } if v.Brack != "" { - p.margin -= 4 + p.margin -= 2 } p.newline() } diff --git a/core/quote.go b/core/quote.go index d5ffe8d45..17559ef92 100644 --- a/core/quote.go +++ b/core/quote.go @@ -191,9 +191,9 @@ const hex = "0123456789abcdef" // quote returns the quoted form of the string value "x". // If triple is true, quote uses the triple-quoted form """x""". func quote(unquoted string, triple bool) string { - q := `"` + q := `'` if triple { - q = `"""` + q = `'''` } var buf bytes.Buffer @@ -201,10 +201,10 @@ func quote(unquoted string, triple bool) string { for i := 0; i < len(unquoted); i++ { c := unquoted[i] - if c == '"' && triple && (i+1 < len(unquoted) && unquoted[i+1] != '"' || i+2 < len(unquoted) && unquoted[i+2] != '"') { + if c == '\'' && triple && (i+1 < len(unquoted) && unquoted[i+1] != '\'' || i+2 < len(unquoted) && unquoted[i+2] != '\'') { // Can pass up to two quotes through, because they are followed by a non-quote byte. buf.WriteByte(c) - if i+1 < len(unquoted) && unquoted[i+1] == '"' { + if i+1 < len(unquoted) && unquoted[i+1] == '\'' { buf.WriteByte(c) i++ } @@ -215,8 +215,8 @@ func quote(unquoted string, triple bool) string { buf.WriteByte(c) continue } - if c == '\'' { - // Can allow ' since we always use ". + if c == '"' { + // Can allow " since we always use '. buf.WriteByte(c) continue }