1) Change default gofmt default settings for

parsing and printing to new syntax.

                  Use -oldparser to parse the old syntax,
                  use -oldprinter to print the old syntax.

               2) Change default gofmt formatting settings
                  to use tabs for indentation only and to use
                  spaces for alignment. This will make the code
                  alignment insensitive to an editor's tabwidth.

                  Use -spaces=false to use tabs for alignment.

               3) Manually changed src/exp/parser/parser_test.go
                  so that it doesn't try to parse the parser's
                  source files using the old syntax (they have
                  new syntax now).

               4) gofmt -w src misc test/bench

	       1st set of files.

R=rsc
CC=agl, golang-dev, iant, ken2, r
https://golang.org/cl/180047
This commit is contained in:
Robert Griesemer 2009-12-15 15:33:31 -08:00
parent 34356e9a6a
commit 5a1d3323fe
139 changed files with 9422 additions and 9422 deletions

View file

@ -11,12 +11,12 @@
package main
import (
"fmt";
"go/ast";
"os";
"fmt"
"go/ast"
"os"
)
func usage() { fmt.Fprint(os.Stderr, "usage: cgo [compiler options] file.go\n") }
func usage() { fmt.Fprint(os.Stderr, "usage: cgo [compiler options] file.go\n") }
var ptrSizeMap = map[string]int64{
"386": 4,
@ -35,29 +35,29 @@ var expandName = map[string]string{
}
func main() {
args := os.Args;
args := os.Args
if len(args) < 2 {
usage();
os.Exit(2);
usage()
os.Exit(2)
}
gccOptions := args[1 : len(args)-1];
input := args[len(args)-1];
gccOptions := args[1 : len(args)-1]
input := args[len(args)-1]
arch := os.Getenv("GOARCH");
arch := os.Getenv("GOARCH")
if arch == "" {
fatal("$GOARCH is not set")
}
ptrSize, ok := ptrSizeMap[arch];
ptrSize, ok := ptrSizeMap[arch]
if !ok {
fatal("unknown architecture %s", arch)
}
// Clear locale variables so gcc emits English errors [sic].
os.Setenv("LANG", "en_US.UTF-8");
os.Setenv("LC_ALL", "C");
os.Setenv("LC_CTYPE", "C");
os.Setenv("LANG", "en_US.UTF-8")
os.Setenv("LC_ALL", "C")
os.Setenv("LC_CTYPE", "C")
p := openProg(input);
p := openProg(input)
for _, cref := range p.Crefs {
// Convert C.ulong to C.unsigned long, etc.
if expand, ok := expandName[cref.Name]; ok {
@ -65,42 +65,42 @@ func main() {
}
}
p.PtrSize = ptrSize;
p.Preamble = p.Preamble + "\n" + builtinProlog;
p.GccOptions = gccOptions;
p.loadDebugInfo();
p.Vardef = make(map[string]*Type);
p.Funcdef = make(map[string]*FuncType);
p.PtrSize = ptrSize
p.Preamble = p.Preamble + "\n" + builtinProlog
p.GccOptions = gccOptions
p.loadDebugInfo()
p.Vardef = make(map[string]*Type)
p.Funcdef = make(map[string]*FuncType)
for _, cref := range p.Crefs {
switch cref.Context {
case "call":
if !cref.TypeName {
// Is an actual function call.
*cref.Expr = &ast.Ident{Value: "_C_" + cref.Name};
p.Funcdef[cref.Name] = cref.FuncType;
break;
*cref.Expr = &ast.Ident{Value: "_C_" + cref.Name}
p.Funcdef[cref.Name] = cref.FuncType
break
}
*cref.Expr = cref.Type.Go;
*cref.Expr = cref.Type.Go
case "expr":
if cref.TypeName {
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.
*cref.Expr = &ast.StarExpr{X: &ast.Ident{Value: "_C_" + cref.Name}};
p.Vardef[cref.Name] = cref.Type;
*cref.Expr = &ast.StarExpr{X: &ast.Ident{Value: "_C_" + cref.Name}}
p.Vardef[cref.Name] = cref.Type
case "type":
if !cref.TypeName {
error((*cref.Expr).Pos(), "expression C.%s used as type", cref.Name)
}
*cref.Expr = cref.Type.Go;
*cref.Expr = cref.Type.Go
}
}
if nerrors > 0 {
os.Exit(2)
}
p.PackagePath = os.Getenv("CGOPKGPATH") + "/" + p.Package;
p.writeOutput(input);
p.PackagePath = os.Getenv("CGOPKGPATH") + "/" + p.Package
p.writeOutput(input)
}