Commit a50cbf6c authored by Russ Cox's avatar Russ Cox

style police: parens in if, for, switch, range

R=r
DELTA=32  (0 added, 3 deleted, 29 changed)
OCL=30718
CL=30725
parent 30533d60
...@@ -27,10 +27,7 @@ func TestClient(t *testing.T) { ...@@ -27,10 +27,7 @@ func TestClient(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("Error fetching URL: %v", err); t.Errorf("Error fetching URL: %v", err);
} else { } else if s := string(b); !strings.HasPrefix(s, "User-agent:") {
s := string(b); t.Errorf("Incorrect page body (did not begin with User-agent): %q", s);
if (!strings.HasPrefix(s, "User-agent:")) {
t.Errorf("Incorrect page body (did not begin with User-agent): %q", s);
}
} }
} }
...@@ -42,7 +42,7 @@ func TestParseForm(t *testing.T) { ...@@ -42,7 +42,7 @@ func TestParseForm(t *testing.T) {
if dlen, olen := len(data), len(test.out); dlen != olen { if dlen, olen := len(data), len(test.out); dlen != olen {
t.Errorf("test %d: Have %d keys, want %d keys", i, dlen, olen); t.Errorf("test %d: Have %d keys, want %d keys", i, dlen, olen);
} }
for k, vs := range(test.out) { for k, vs := range test.out {
vec, ok := data[k]; vec, ok := data[k];
if !ok { if !ok {
t.Errorf("test %d: Missing key %q", i, k); t.Errorf("test %d: Missing key %q", i, k);
...@@ -52,7 +52,7 @@ func TestParseForm(t *testing.T) { ...@@ -52,7 +52,7 @@ func TestParseForm(t *testing.T) {
t.Errorf("test %d: key %q: Have %d keys, want %d keys", i, k, dlen, olen); t.Errorf("test %d: key %q: Have %d keys, want %d keys", i, k, dlen, olen);
continue continue
} }
for j, v := range(vs) { for j, v := range vs {
if dv := vec.At(j); dv != v { if dv := vec.At(j); dv != v {
t.Errorf("test %d: key %q: val %d: Have %q, want %q", i, k, j, dv, v); t.Errorf("test %d: key %q: val %d: Have %q, want %q", i, k, j, dv, v);
} }
......
...@@ -108,8 +108,8 @@ func URLEscape(s string) string { ...@@ -108,8 +108,8 @@ func URLEscape(s string) string {
spaceCount, hexCount := 0, 0; spaceCount, hexCount := 0, 0;
for i := 0; i < len(s); i++ { for i := 0; i < len(s); i++ {
c := s[i]; c := s[i];
if (shouldEscape(c)) { if shouldEscape(c) {
if (c == ' ') { if c == ' ' {
spaceCount++; spaceCount++;
} else { } else {
hexCount++; hexCount++;
...@@ -128,7 +128,7 @@ func URLEscape(s string) string { ...@@ -128,7 +128,7 @@ func URLEscape(s string) string {
if !shouldEscape(c) { if !shouldEscape(c) {
t[j] = s[i]; t[j] = s[i];
j++; j++;
} else if (c == ' ') { } else if c == ' ' {
t[j] = '+'; t[j] = '+';
j++; j++;
} else { } else {
...@@ -256,10 +256,10 @@ func ParseURL(rawurl string) (url *URL, err os.Error) { ...@@ -256,10 +256,10 @@ func ParseURL(rawurl string) (url *URL, err os.Error) {
if url.Userinfo, err = URLUnescape(url.Userinfo); err != nil { if url.Userinfo, err = URLUnescape(url.Userinfo); err != nil {
return nil, err return nil, err
} }
if (strings.Index(url.Scheme, "%") >= 0) { if strings.Index(url.Scheme, "%") >= 0 {
return nil, BadURL{"hexadecimal escape in scheme"} return nil, BadURL{"hexadecimal escape in scheme"}
} }
if (strings.Index(url.Host, "%") >= 0) { if strings.Index(url.Host, "%") >= 0 {
return nil, BadURL{"hexadecimal escape in host"} return nil, BadURL{"hexadecimal escape in host"}
} }
......
...@@ -75,7 +75,7 @@ func testLog(t *testing.T, flag int, prefix string, pattern string, useLogf bool ...@@ -75,7 +75,7 @@ func testLog(t *testing.T, flag int, prefix string, pattern string, useLogf bool
} }
func TestAllLog(t *testing.T) { func TestAllLog(t *testing.T) {
for i, testcase := range(tests) { for i, testcase := range tests {
testLog(t, testcase.flag, testcase.prefix, testcase.pattern, false); testLog(t, testcase.flag, testcase.prefix, testcase.pattern, false);
testLog(t, testcase.flag, testcase.prefix, testcase.pattern, true); testLog(t, testcase.flag, testcase.prefix, testcase.pattern, true);
} }
......
...@@ -20,7 +20,7 @@ func sinus(x float64, quad int) float64 { ...@@ -20,7 +20,7 @@ func sinus(x float64, quad int) float64 {
Q2 = .9463096101538208180571257e4; Q2 = .9463096101538208180571257e4;
Q3 = .1326534908786136358911494e3; Q3 = .1326534908786136358911494e3;
) )
if(x < 0) { if x < 0 {
x = -x; x = -x;
quad = quad+2; quad = quad+2;
} }
......
...@@ -27,7 +27,7 @@ func Tan(x float64) float64 { ...@@ -27,7 +27,7 @@ func Tan(x float64) float64 {
flag := false; flag := false;
sign := false; sign := false;
if(x < 0) { if x < 0 {
x = -x; x = -x;
sign = true; sign = true;
} }
...@@ -55,7 +55,7 @@ func Tan(x float64) float64 { ...@@ -55,7 +55,7 @@ func Tan(x float64) float64 {
temp = temp/(((xsq+Q2)*xsq+Q1)*xsq+Q0); temp = temp/(((xsq+Q2)*xsq+Q1)*xsq+Q0);
if flag { if flag {
if(temp == 0) { if temp == 0 {
panic(NaN()); panic(NaN());
} }
temp = 1/temp; temp = 1/temp;
......
...@@ -68,7 +68,7 @@ func Environ() []string { ...@@ -68,7 +68,7 @@ func Environ() []string {
once.Do(copyenv); once.Do(copyenv);
a := make([]string, len(env)); a := make([]string, len(env));
i := 0; i := 0;
for k, v := range(env) { for k, v := range env {
// check i < len(a) for safety, // check i < len(a) for safety,
// in case env is changing underfoot. // in case env is changing underfoot.
if i < len(a) { if i < len(a) {
......
...@@ -21,7 +21,7 @@ func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*File ...@@ -21,7 +21,7 @@ func ForkExec(argv0 string, argv []string, envv []string, dir string, fd []*File
{ {
// Create array of integer (system) fds. // Create array of integer (system) fds.
intfd := make([]int, len(fd)); intfd := make([]int, len(fd));
for i, f := range(fd) { for i, f := range fd {
if f == nil { if f == nil {
intfd[i] = -1; intfd[i] = -1;
} else { } else {
......
...@@ -77,7 +77,7 @@ func typeToString(typ Type, expand bool) string { ...@@ -77,7 +77,7 @@ func typeToString(typ Type, expand bool) string {
if name := typ.Name(); !expand && name != "" { if name := typ.Name(); !expand && name != "" {
return name return name
} }
switch(typ.Kind()) { switch typ.Kind() {
case MissingKind: case MissingKind:
return "$missing$"; return "$missing$";
case IntKind, Int8Kind, Int16Kind, Int32Kind, Int64Kind, case IntKind, Int8Kind, Int16Kind, Int32Kind, Int64Kind,
...@@ -141,7 +141,7 @@ func integer(v int64) string { ...@@ -141,7 +141,7 @@ func integer(v int64) string {
func valueToString(val Value) string { func valueToString(val Value) string {
var str string; var str string;
typ := val.Type(); typ := val.Type();
switch(val.Kind()) { switch val.Kind() {
case MissingKind: case MissingKind:
return "missing"; return "missing";
case IntKind: case IntKind:
......
...@@ -397,7 +397,7 @@ func (t *structTypeStruct) Size() int { ...@@ -397,7 +397,7 @@ func (t *structTypeStruct) Size() int {
t.field[i].offset = size; t.field[i].offset = size;
size += elemsize; size += elemsize;
} }
if (structAlignMask > 0) { if structAlignMask > 0 {
// 6g etc. always aligns structs to a minimum size, typically int64 // 6g etc. always aligns structs to a minimum size, typically int64
if structAlignMask < minStructAlignMask { if structAlignMask < minStructAlignMask {
structAlignMask = minStructAlignMask structAlignMask = minStructAlignMask
......
...@@ -328,7 +328,7 @@ func (a *decimal) Round(nd int) *decimal { ...@@ -328,7 +328,7 @@ func (a *decimal) Round(nd int) *decimal {
if nd <= 0 || nd >= a.nd { if nd <= 0 || nd >= a.nd {
return a; return a;
} }
if(shouldRoundUp(a, nd)) { if shouldRoundUp(a, nd) {
return a.RoundUp(nd); return a.RoundUp(nd);
} }
return a.RoundDown(nd); return a.RoundDown(nd);
......
...@@ -66,7 +66,7 @@ var lastIndexTests = []IndexTest { ...@@ -66,7 +66,7 @@ var lastIndexTests = []IndexTest {
func runIndexTests(t *testing.T, f func(s, sep string) int, funcName string, testCases []IndexTest) { func runIndexTests(t *testing.T, f func(s, sep string) int, funcName string, testCases []IndexTest) {
for i,test := range testCases { for i,test := range testCases {
actual := f(test.s, test.sep); actual := f(test.s, test.sep);
if (actual != test.out) { if actual != test.out {
t.Errorf("%s(%q,%q) = %v; want %v", funcName, test.s, test.sep, actual, test.out); t.Errorf("%s(%q,%q) = %v; want %v", funcName, test.s, test.sep, actual, test.out);
} }
} }
...@@ -149,7 +149,7 @@ type StringTest struct { ...@@ -149,7 +149,7 @@ type StringTest struct {
func runStringTests(t *testing.T, f func(string) string, funcName string, testCases []StringTest) { func runStringTests(t *testing.T, f func(string) string, funcName string, testCases []StringTest) {
for i, tc := range testCases { for i, tc := range testCases {
actual := f(tc.in); actual := f(tc.in);
if (actual != tc.out) { if actual != tc.out {
t.Errorf("%s(%q) = %q; want %q", funcName, tc.in, actual, tc.out); t.Errorf("%s(%q) = %q; want %q", funcName, tc.in, actual, tc.out);
} }
} }
......
...@@ -362,12 +362,12 @@ var testLetter = []int{ ...@@ -362,12 +362,12 @@ var testLetter = []int{
} }
func TestIsDecimalDigit(t *testing.T) { func TestIsDecimalDigit(t *testing.T) {
for i, r := range(testDecimal) { for i, r := range testDecimal {
if !IsDecimalDigit(r) { if !IsDecimalDigit(r) {
t.Errorf("IsDecimalDigit(%#x) = false, want true\n", r); t.Errorf("IsDecimalDigit(%#x) = false, want true\n", r);
} }
} }
for i, r := range(testLetter) { for i, r := range testLetter {
if IsDecimalDigit(r) { if IsDecimalDigit(r) {
t.Errorf("IsDecimalDigit(%#x) = true, want false\n", r); t.Errorf("IsDecimalDigit(%#x) = true, want false\n", r);
} }
......
...@@ -93,17 +93,17 @@ var notletter = []int{ ...@@ -93,17 +93,17 @@ var notletter = []int{
} }
func TestIsLetter(t *testing.T) { func TestIsLetter(t *testing.T) {
for i, r := range(upper) { for i, r := range upper {
if !IsLetter(r) { if !IsLetter(r) {
t.Errorf("IsLetter(%#x) = false, want true\n", r); t.Errorf("IsLetter(%#x) = false, want true\n", r);
} }
} }
for i, r := range(letter) { for i, r := range letter {
if !IsLetter(r) { if !IsLetter(r) {
t.Errorf("IsLetter(%#x) = false, want true\n", r); t.Errorf("IsLetter(%#x) = false, want true\n", r);
} }
} }
for i, r := range(notletter) { for i, r := range notletter {
if IsLetter(r) { if IsLetter(r) {
t.Errorf("IsLetter(%#x) = true, want false\n", r); t.Errorf("IsLetter(%#x) = true, want false\n", r);
} }
...@@ -111,17 +111,17 @@ func TestIsLetter(t *testing.T) { ...@@ -111,17 +111,17 @@ func TestIsLetter(t *testing.T) {
} }
func TestIsUpper(t *testing.T) { func TestIsUpper(t *testing.T) {
for i, r := range(upper) { for i, r := range upper {
if !IsUpper(r) { if !IsUpper(r) {
t.Errorf("IsUpper(%#x) = false, want true\n", r); t.Errorf("IsUpper(%#x) = false, want true\n", r);
} }
} }
for i, r := range(notupper) { for i, r := range notupper {
if IsUpper(r) { if IsUpper(r) {
t.Errorf("IsUpper(%#x) = true, want false\n", r); t.Errorf("IsUpper(%#x) = true, want false\n", r);
} }
} }
for i, r := range(notletter) { for i, r := range notletter {
if IsUpper(r) { if IsUpper(r) {
t.Errorf("IsUpper(%#x) = true, want false\n", r); t.Errorf("IsUpper(%#x) = true, want false\n", r);
} }
......
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