Skip to content

Commit

Permalink
Change settings to match style used for BUCK files.
Browse files Browse the repository at this point in the history
  • Loading branch information
bolinfest committed Jan 12, 2017
1 parent 762ecbc commit 68b6d08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions core/print.go
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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--
Expand Down Expand Up @@ -563,7 +563,7 @@ func (p *printer) listFor(v *ListForExpr) {

if multiLine {
if v.Brack != "" {
p.margin += 4
p.margin += 2
}
p.newline()
}
Expand Down Expand Up @@ -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()
}
Expand Down
12 changes: 6 additions & 6 deletions core/quote.go
Expand Up @@ -191,20 +191,20 @@ 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
buf.WriteString(q)

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++
}
Expand All @@ -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
}
Expand Down

0 comments on commit 68b6d08

Please sign in to comment.