diff options
Diffstat (limited to 'src/cmd/cgo')
-rw-r--r-- | src/cmd/cgo/ast.go | 72 | ||||
-rw-r--r-- | src/cmd/cgo/gcc.go | 144 | ||||
-rw-r--r-- | src/cmd/cgo/main.go | 12 | ||||
-rw-r--r-- | src/cmd/cgo/out.go | 10 | ||||
-rw-r--r-- | src/cmd/cgo/util.go | 16 |
5 files changed, 127 insertions, 127 deletions
diff --git a/src/cmd/cgo/ast.go b/src/cmd/cgo/ast.go index e5956375c..f739c355a 100644 --- a/src/cmd/cgo/ast.go +++ b/src/cmd/cgo/ast.go @@ -65,7 +65,7 @@ func openProg(name string) *Prog { // Instead, turn it into a new Error that will return // details for all the errors. for _, e := range list { - fmt.Fprintln(os.Stderr, e); + fmt.Fprintln(os.Stderr, e) } os.Exit(2); } @@ -94,16 +94,16 @@ func openProg(name string) *Prog { } sawC = true; if s.Name != nil { - error(s.Path[0].Pos(), `cannot rename import "C"`); + error(s.Path[0].Pos(), `cannot rename import "C"`) } if s.Doc != nil { - p.Preamble += doc.CommentText(s.Doc) + "\n"; + p.Preamble += doc.CommentText(s.Doc) + "\n" } else if len(d.Specs) == 1 && d.Doc != nil { - p.Preamble += doc.CommentText(d.Doc) + "\n"; + p.Preamble += doc.CommentText(d.Doc) + "\n" } } if ws == 0 { - continue; + continue } d.Specs = d.Specs[0:ws]; p.AST.Decls[w] = d; @@ -112,7 +112,7 @@ func openProg(name string) *Prog { p.AST.Decls = p.AST.Decls[0:w]; if !sawC { - error(noPos, `cannot find import "C"`); + error(noPos, `cannot find import "C"`) } // Accumulate pointers to uses of C.x. @@ -135,7 +135,7 @@ func walk(x interface{}, p *Prog, context string) { if i >= cap(p.Crefs) { new := make([]*Cref, 2*i); for j, v := range p.Crefs { - new[j] = v; + new[j] = v } p.Crefs = new; } @@ -159,7 +159,7 @@ func walk(x interface{}, p *Prog, context string) { // These are ordered and grouped to match ../../pkg/go/ast/ast.go case *ast.Field: - walk(&n.Type, p, "type"); + walk(&n.Type, p, "type") case *ast.BadExpr: case *ast.Ident: case *ast.Ellipsis: @@ -172,14 +172,14 @@ func walk(x interface{}, p *Prog, context string) { walk(&n.Type, p, "type"); walk(n.Elts, p, "expr"); case *ast.ParenExpr: - walk(&n.X, p, context); + walk(&n.X, p, context) case *ast.SelectorExpr: - walk(&n.X, p, "selector"); + walk(&n.X, p, "selector") case *ast.IndexExpr: walk(&n.X, p, "expr"); walk(&n.Index, p, "expr"); if n.End != nil { - walk(&n.End, p, "expr"); + walk(&n.End, p, "expr") } case *ast.TypeAssertExpr: walk(&n.X, p, "expr"); @@ -188,9 +188,9 @@ func walk(x interface{}, p *Prog, context string) { walk(&n.Fun, p, "call"); walk(n.Args, p, "expr"); case *ast.StarExpr: - walk(&n.X, p, context); + walk(&n.X, p, context) case *ast.UnaryExpr: - walk(&n.X, p, "expr"); + walk(&n.X, p, "expr") case *ast.BinaryExpr: walk(&n.X, p, "expr"); walk(&n.Y, p, "expr"); @@ -202,40 +202,40 @@ func walk(x interface{}, p *Prog, context string) { walk(&n.Len, p, "expr"); walk(&n.Elt, p, "type"); case *ast.StructType: - walk(n.Fields, p, "field"); + walk(n.Fields, p, "field") case *ast.FuncType: walk(n.Params, p, "field"); walk(n.Results, p, "field"); case *ast.InterfaceType: - walk(n.Methods, p, "field"); + walk(n.Methods, p, "field") case *ast.MapType: walk(&n.Key, p, "type"); walk(&n.Value, p, "type"); case *ast.ChanType: - walk(&n.Value, p, "type"); + walk(&n.Value, p, "type") case *ast.BadStmt: case *ast.DeclStmt: - walk(n.Decl, p, "decl"); + walk(n.Decl, p, "decl") case *ast.EmptyStmt: case *ast.LabeledStmt: - walk(n.Stmt, p, "stmt"); + walk(n.Stmt, p, "stmt") case *ast.ExprStmt: - walk(&n.X, p, "expr"); + walk(&n.X, p, "expr") case *ast.IncDecStmt: - walk(&n.X, p, "expr"); + walk(&n.X, p, "expr") case *ast.AssignStmt: walk(n.Lhs, p, "expr"); walk(n.Rhs, p, "expr"); case *ast.GoStmt: - walk(n.Call, p, "expr"); + walk(n.Call, p, "expr") case *ast.DeferStmt: - walk(n.Call, p, "expr"); + walk(n.Call, p, "expr") case *ast.ReturnStmt: - walk(n.Results, p, "expr"); + walk(n.Results, p, "expr") case *ast.BranchStmt: case *ast.BlockStmt: - walk(n.List, p, "stmt"); + walk(n.List, p, "stmt") case *ast.IfStmt: walk(n.Init, p, "stmt"); walk(&n.Cond, p, "expr"); @@ -260,7 +260,7 @@ func walk(x interface{}, p *Prog, context string) { walk(n.Rhs, p, "expr"); walk(n.Body, p, "stmt"); case *ast.SelectStmt: - walk(n.Body, p, "stmt"); + walk(n.Body, p, "stmt") case *ast.ForStmt: walk(n.Init, p, "stmt"); walk(&n.Cond, p, "expr"); @@ -277,47 +277,47 @@ func walk(x interface{}, p *Prog, context string) { walk(&n.Type, p, "type"); walk(n.Values, p, "expr"); case *ast.TypeSpec: - walk(&n.Type, p, "type"); + walk(&n.Type, p, "type") case *ast.BadDecl: case *ast.GenDecl: - walk(n.Specs, p, "spec"); + walk(n.Specs, p, "spec") case *ast.FuncDecl: if n.Recv != nil { - walk(n.Recv, p, "field"); + walk(n.Recv, p, "field") } walk(n.Type, p, "type"); if n.Body != nil { - walk(n.Body, p, "stmt"); + walk(n.Body, p, "stmt") } case *ast.File: - walk(n.Decls, p, "decl"); + walk(n.Decls, p, "decl") case *ast.Package: for _, f := range n.Files { - walk(f, p, "file"); + walk(f, p, "file") } case []ast.Decl: for _, d := range n { - walk(d, p, context); + walk(d, p, context) } case []ast.Expr: for i := range n { - walk(&n[i], p, context); + walk(&n[i], p, context) } case []*ast.Field: for _, f := range n { - walk(f, p, context); + walk(f, p, context) } case []ast.Stmt: for _, s := range n { - walk(s, p, context); + walk(s, p, context) } case []ast.Spec: for _, s := range n { - walk(s, p, context); + walk(s, p, context) } } } diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 9087c9197..f5c33e82c 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -24,7 +24,7 @@ func (p *Prog) loadDebugInfo() { // Construct a slice of unique names from p.Crefs. m := make(map[string]int); for _, c := range p.Crefs { - m[c.Name] = -1; + m[c.Name] = -1 } names := make([]string, 0, len(m)); for name, _ := range m { @@ -59,40 +59,40 @@ func (p *Prog) loadDebugInfo() { kind := make(map[string]string); _, stderr := p.gccDebug(b.Bytes()); if stderr == "" { - fatal("gcc produced no output"); + fatal("gcc produced no output") } for _, line := range strings.Split(stderr, "\n", 0) { if len(line) < 9 || line[0:9] != "cgo-test:" { - continue; + continue } line = line[9:len(line)]; colon := strings.Index(line, ":"); if colon < 0 { - continue; + continue } i, err := strconv.Atoi(line[0:colon]); if err != nil { - continue; + continue } what := ""; switch { default: - continue; + continue case strings.Index(line, ": useless type name in empty declaration") >= 0: - what = "type"; + what = "type" case strings.Index(line, ": statement with no effect") >= 0: - what = "value"; + what = "value" case strings.Index(line, "undeclared") >= 0: - what = "error"; + what = "error" } if old, ok := kind[names[i]]; ok && old != what { - error(noPos, "inconsistent gcc output about C.%s", names[i]); + error(noPos, "inconsistent gcc output about C.%s", names[i]) } kind[names[i]] = what; } for _, n := range names { if _, ok := kind[n]; !ok { - error(noPos, "could not determine kind of name for C.%s", n); + error(noPos, "could not determine kind of name for C.%s", n) } } @@ -107,11 +107,11 @@ func (p *Prog) loadDebugInfo() { b.Reset(); b.WriteString(p.Preamble); for i, n := range names { - fmt.Fprintf(&b, "typeof(%s) *__cgo__%d;\n", n, i); + fmt.Fprintf(&b, "typeof(%s) *__cgo__%d;\n", n, i) } d, stderr := p.gccDebug(b.Bytes()); if d == nil { - fatal("gcc failed:\n%s\non input:\n%s", stderr, b.Bytes()); + fatal("gcc failed:\n%s\non input:\n%s", stderr, b.Bytes()) } // Scan DWARF info for top-level TagVariable entries with AttrName __cgo__i. @@ -120,39 +120,39 @@ func (p *Prog) loadDebugInfo() { for { e, err := r.Next(); if err != nil { - fatal("reading DWARF entry: %s", err); + fatal("reading DWARF entry: %s", err) } if e == nil { - break; + break } if e.Tag != dwarf.TagVariable { - goto Continue; + goto Continue } name, _ := e.Val(dwarf.AttrName).(string); typOff, _ := e.Val(dwarf.AttrType).(dwarf.Offset); if name == "" || typOff == 0 { - fatal("malformed DWARF TagVariable entry"); + fatal("malformed DWARF TagVariable entry") } if !strings.HasPrefix(name, "__cgo__") { - goto Continue; + goto Continue } typ, err := d.Type(typOff); if err != nil { - fatal("loading DWARF type: %s", err); + fatal("loading DWARF type: %s", err) } t, ok := typ.(*dwarf.PtrType); if !ok || t == nil { - fatal("internal error: %s has non-pointer type", name); + fatal("internal error: %s has non-pointer type", name) } i, err := strconv.Atoi(name[7:len(name)]); if err != nil { - fatal("malformed __cgo__ name: %s", name); + fatal("malformed __cgo__ name: %s", name) } types[i] = t.Type; Continue: if e.Tag != dwarf.TagCompileUnit { - r.SkipChildren(); + r.SkipChildren() } } @@ -164,9 +164,9 @@ func (p *Prog) loadDebugInfo() { c.TypeName = kind[c.Name] == "type"; f, fok := types[i].(*dwarf.FuncType); if c.Context == "call" && !c.TypeName && fok { - c.FuncType = conv.FuncType(f); + c.FuncType = conv.FuncType(f) } else { - c.Type = conv.Type(types[i]); + c.Type = conv.Type(types[i]) } } p.Typedef = conv.typedef; @@ -175,10 +175,10 @@ func (p *Prog) loadDebugInfo() { func concat(a, b []string) []string { c := make([]string, len(a)+len(b)); for i, s := range a { - c[i] = s; + c[i] = s } for i, s := range b { - c[i+len(a)] = s; + c[i+len(a)] = s } return c; } @@ -189,7 +189,7 @@ func concat(a, b []string) []string { func (p *Prog) gccDebug(stdin []byte) (*dwarf.Data, string) { machine := "-m32"; if p.PtrSize == 8 { - machine = "-m64"; + machine = "-m64" } tmp := "_cgo_.o"; @@ -206,7 +206,7 @@ func (p *Prog) gccDebug(stdin []byte) (*dwarf.Data, string) { }; _, stderr, ok := run(stdin, concat(base, p.GccOptions)); if !ok { - return nil, string(stderr); + return nil, string(stderr) } // Try to parse f as ELF and Mach-O and hope one works. @@ -216,13 +216,13 @@ func (p *Prog) gccDebug(stdin []byte) (*dwarf.Data, string) { var err os.Error; if f, err = elf.Open(tmp); err != nil { if f, err = macho.Open(tmp); err != nil { - fatal("cannot parse gcc output %s as ELF or Mach-O object", tmp); + fatal("cannot parse gcc output %s as ELF or Mach-O object", tmp) } } d, err := f.DWARF(); if err != nil { - fatal("cannot load DWARF debug information from %s: %s", tmp, err); + fatal("cannot load DWARF debug information from %s: %s", tmp, err) } return d, ""; } @@ -302,7 +302,7 @@ var cnameMap = map[string]string{ func (c *typeConv) Type(dtype dwarf.Type) *Type { if t, ok := c.m[dtype]; ok { if t.Go == nil { - fatal("type conversion loop at %s", dtype); + fatal("type conversion loop at %s", dtype) } return t; } @@ -312,17 +312,17 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type { t.Align = -1; t.C = dtype.Common().Name; if t.Size < 0 { - fatal("dwarf.Type %s reports unknown size", dtype); + fatal("dwarf.Type %s reports unknown size", dtype) } c.m[dtype] = t; switch dt := dtype.(type) { default: - fatal("unexpected type: %s", dtype); + fatal("unexpected type: %s", dtype) case *dwarf.AddrType: if t.Size != c.ptrSize { - fatal("unexpected: %d-byte address type - %s", t.Size, dtype); + fatal("unexpected: %d-byte address type - %s", t.Size, dtype) } t.Go = c.uintptr; t.Align = t.Size; @@ -344,7 +344,7 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type { case *dwarf.CharType: if t.Size != 1 { - fatal("unexpected: %d-byte char type - %s", t.Size, dtype); + fatal("unexpected: %d-byte char type - %s", t.Size, dtype) } t.Go = c.int8; t.Align = 1; @@ -352,32 +352,32 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type { case *dwarf.EnumType: switch t.Size { default: - fatal("unexpected: %d-byte enum type - %s", t.Size, dtype); + fatal("unexpected: %d-byte enum type - %s", t.Size, dtype) case 1: - t.Go = c.uint8; + t.Go = c.uint8 case 2: - t.Go = c.uint16; + t.Go = c.uint16 case 4: - t.Go = c.uint32; + t.Go = c.uint32 case 8: - t.Go = c.uint64; + t.Go = c.uint64 } if t.Align = t.Size; t.Align >= c.ptrSize { - t.Align = c.ptrSize; + t.Align = c.ptrSize } t.C = "enum " + dt.EnumName; case *dwarf.FloatType: switch t.Size { default: - fatal("unexpected: %d-byte float type - %s", t.Size, dtype); + fatal("unexpected: %d-byte float type - %s", t.Size, dtype) case 4: - t.Go = c.float32; + t.Go = c.float32 case 8: - t.Go = c.float64; + t.Go = c.float64 } if t.Align = t.Size; t.Align >= c.ptrSize { - t.Align = c.ptrSize; + t.Align = c.ptrSize } case *dwarf.FuncType: @@ -388,22 +388,22 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type { case *dwarf.IntType: if dt.BitSize > 0 { - fatal("unexpected: %d-bit int type - %s", dt.BitSize, dtype); + fatal("unexpected: %d-bit int type - %s", dt.BitSize, dtype) } switch t.Size { default: - fatal("unexpected: %d-byte int type - %s", t.Size, dtype); + fatal("unexpected: %d-byte int type - %s", t.Size, dtype) case 1: - t.Go = c.int8; + t.Go = c.int8 case 2: - t.Go = c.int16; + t.Go = c.int16 case 4: - t.Go = c.int32; + t.Go = c.int32 case 8: - t.Go = c.int64; + t.Go = c.int64 } if t.Align = t.Size; t.Align >= c.ptrSize { - t.Align = c.ptrSize; + t.Align = c.ptrSize } case *dwarf.PtrType: @@ -436,7 +436,7 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type { tag = "__" + strconv.Itoa(c.tagGen); c.tagGen++; } else if t.C == "" { - t.C = dt.Kind + " " + tag; + t.C = dt.Kind + " " + tag } name := c.Ident("_C" + dt.Kind + "_" + tag); t.Go = name; // publish before recursive calls @@ -444,12 +444,12 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type { case "union", "class": c.typedef[name.Value] = c.Opaque(t.Size); if t.C == "" { - t.C = fmt.Sprintf("typeof(unsigned char[%d])", t.Size); + t.C = fmt.Sprintf("typeof(unsigned char[%d])", t.Size) } case "struct": g, csyntax, align := c.Struct(dt); if t.C == "" { - t.C = csyntax; + t.C = csyntax } t.Align = align; c.typedef[name.Value] = g; @@ -472,34 +472,34 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type { t.Size = sub.Size; t.Align = sub.Align; if _, ok := c.typedef[name.Value]; !ok { - c.typedef[name.Value] = sub.Go; + c.typedef[name.Value] = sub.Go } case *dwarf.UcharType: if t.Size != 1 { - fatal("unexpected: %d-byte uchar type - %s", t.Size, dtype); + fatal("unexpected: %d-byte uchar type - %s", t.Size, dtype) } t.Go = c.uint8; t.Align = 1; case *dwarf.UintType: if dt.BitSize > 0 { - fatal("unexpected: %d-bit uint type - %s", dt.BitSize, dtype); + fatal("unexpected: %d-bit uint type - %s", dt.BitSize, dtype) } switch t.Size { default: - fatal("unexpected: %d-byte uint type - %s", t.Size, dtype); + fatal("unexpected: %d-byte uint type - %s", t.Size, dtype) case 1: - t.Go = c.uint8; + t.Go = c.uint8 case 2: - t.Go = c.uint16; + t.Go = c.uint16 case 4: - t.Go = c.uint32; + t.Go = c.uint32 case 8: - t.Go = c.uint64; + t.Go = c.uint64 } if t.Align = t.Size; t.Align >= c.ptrSize { - t.Align = c.ptrSize; + t.Align = c.ptrSize } case *dwarf.VoidType: @@ -512,7 +512,7 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type { s := dtype.Common().Name; if s != "" { if ss, ok := cnameMap[s]; ok { - s = ss; + s = ss } s = strings.Join(strings.Split(s, " ", 0), ""); // strip spaces name := c.Ident("_C_"+s); @@ -522,7 +522,7 @@ func (c *typeConv) Type(dtype dwarf.Type) *Type { } if t.C == "" { - fatal("internal error: did not create C name for %s", dtype); + fatal("internal error: did not create C name for %s", dtype) } return t; @@ -541,14 +541,14 @@ func (c *typeConv) FuncArg(dtype dwarf.Type) *Type { Align: c.ptrSize, Go: &ast.StarExpr{X: t.Go}, C: t.C + "*", - }; + } case *dwarf.TypedefType: // C has much more relaxed rules than Go for // implicit type conversions. When the parameter // is type T defined as *X, simulate a little of the // laxness of C by making the argument *X instead of T. if ptr, ok := base(dt.Type).(*dwarf.PtrType); ok { - return c.Type(ptr); + return c.Type(ptr) } } return t; @@ -587,7 +587,7 @@ func (c *typeConv) Opaque(n int64) ast.Expr { return &ast.ArrayType{ Len: c.intExpr(n), Elt: c.byte, - }; + } } // Expr for integer n. @@ -595,7 +595,7 @@ func (c *typeConv) intExpr(n int64) ast.Expr { return &ast.BasicLit{ Kind: token.INT, Value: strings.Bytes(strconv.Itoa64(n)), - }; + } } // Add padding of given size to fld. @@ -623,7 +623,7 @@ func (c *typeConv) Struct(dt *dwarf.StructType) (expr *ast.StructType, csyntax s off += t.Size; csyntax += t.C + " " + f.Name + "; "; if t.Align > align { - align = t.Align; + align = t.Align } } if off < dt.ByteSize { @@ -631,7 +631,7 @@ func (c *typeConv) Struct(dt *dwarf.StructType) (expr *ast.StructType, csyntax s off = dt.ByteSize; } if off != dt.ByteSize { - fatal("struct size calculation error"); + fatal("struct size calculation error") } csyntax += "}"; expr = &ast.StructType{Fields: fld}; diff --git a/src/cmd/cgo/main.go b/src/cmd/cgo/main.go index c80170478..1eadfba9b 100644 --- a/src/cmd/cgo/main.go +++ b/src/cmd/cgo/main.go @@ -45,18 +45,18 @@ func main() { arch := os.Getenv("GOARCH"); if arch == "" { - fatal("$GOARCH is not set"); + fatal("$GOARCH is not set") } ptrSize, ok := ptrSizeMap[arch]; if !ok { - fatal("unknown architecture %s", arch); + fatal("unknown architecture %s", arch) } p := openProg(input); for _, cref := range p.Crefs { // Convert C.ulong to C.unsigned long, etc. if expand, ok := expandName[cref.Name]; ok { - cref.Name = expand; + cref.Name = expand } } @@ -79,7 +79,7 @@ func main() { *cref.Expr = cref.Type.Go; case "expr": if cref.TypeName { - error((*cref.Expr).Pos(), "type C.%s used as expression", cref.Name); + error((*cref.Expr).Pos(), "type C.%s used as expression", cref.Name) } // Reference to C variable. // We declare a pointer and arrange to have it filled in. @@ -87,13 +87,13 @@ func main() { p.Vardef[cref.Name] = cref.Type; case "type": if !cref.TypeName { - error((*cref.Expr).Pos(), "expression C.%s used as type", cref.Name); + error((*cref.Expr).Pos(), "expression C.%s used as type", cref.Name) } *cref.Expr = cref.Type.Go; } } if nerrors > 0 { - os.Exit(2); + os.Exit(2) } p.PackagePath = p.Package; diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 2ae56fc28..2a62233b7 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -15,7 +15,7 @@ import ( func creat(name string) *os.File { f, err := os.Open(name, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0666); if err != nil { - fatal("%s", err); + fatal("%s", err) } return f; } @@ -27,7 +27,7 @@ func (p *Prog) writeOutput(srcfile string) { base := srcfile; if strings.HasSuffix(base, ".go") { - base = base[0 : len(base)-3]; + base = base[0 : len(base)-3] } fgo1 := creat(base + ".cgo1.go"); fgo2 := creat(base + ".cgo2.go"); @@ -80,7 +80,7 @@ func (p *Prog) writeOutput(srcfile string) { if name == "CString" || name == "GoString" { // The builtins are already defined in the C prolog. - continue; + continue } // Construct a gcc struct matching the 6c argument frame. @@ -150,12 +150,12 @@ func (p *Prog) writeOutput(srcfile string) { fmt.Fprintf(fgcc, "\t%s *a = v;\n", structType); fmt.Fprintf(fgcc, "\t"); if def.Result != nil { - fmt.Fprintf(fgcc, "a->r = "); + fmt.Fprintf(fgcc, "a->r = ") } fmt.Fprintf(fgcc, "%s(", name); for i := range def.Params { if i > 0 { - fmt.Fprintf(fgcc, ", "); + fmt.Fprintf(fgcc, ", ") } fmt.Fprintf(fgcc, "a->p%d", i); } diff --git a/src/cmd/cgo/util.go b/src/cmd/cgo/util.go index a2a013180..d91516eb9 100644 --- a/src/cmd/cgo/util.go +++ b/src/cmd/cgo/util.go @@ -18,7 +18,7 @@ type ByteReaderAt []byte func (r ByteReaderAt) ReadAt(p []byte, off int64) (n int, err os.Error) { if off >= int64(len(r)) || off < 0 { - return 0, os.EOF; + return 0, os.EOF } return bytes.Copy(p, r[off:len(r)]), nil; } @@ -29,23 +29,23 @@ func (r ByteReaderAt) ReadAt(p []byte, off int64) (n int, err os.Error) { func run(stdin []byte, argv []string) (stdout, stderr []byte, ok bool) { cmd, err := exec.LookPath(argv[0]); if err != nil { - fatal("exec %s: %s", argv[0], err); + fatal("exec %s: %s", argv[0], err) } r0, w0, err := os.Pipe(); if err != nil { - fatal("%s", err); + fatal("%s", err) } r1, w1, err := os.Pipe(); if err != nil { - fatal("%s", err); + fatal("%s", err) } r2, w2, err := os.Pipe(); if err != nil { - fatal("%s", err); + fatal("%s", err) } pid, err := os.ForkExec(cmd, argv, os.Environ(), "", []*os.File{r0, w1, w2}); if err != nil { - fatal("%s", err); + fatal("%s", err) } r0.Close(); w1.Close(); @@ -70,7 +70,7 @@ func run(stdin []byte, argv []string) (stdout, stderr []byte, ok bool) { w, err := os.Wait(pid, 0); if err != nil { - fatal("%s", err); + fatal("%s", err) } ok = w.Exited() && w.ExitStatus() == 0; return; @@ -88,7 +88,7 @@ var noPos token.Position func error(pos token.Position, msg string, args ...) { nerrors++; if pos.IsValid() { - fmt.Fprintf(os.Stderr, "%s: ", pos); + fmt.Fprintf(os.Stderr, "%s: ", pos) } fmt.Fprintf(os.Stderr, msg, args); fmt.Fprintf(os.Stderr, "\n"); |