From 3743fa38e180c74c51aae84eda082067e8e12523 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 15 Dec 2009 15:41:46 -0800 Subject: 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 5th and last set of files. R=rsc CC=golang-dev http://codereview.appspot.com/180050 --- test/bench/regex-dna.go | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'test/bench/regex-dna.go') diff --git a/test/bench/regex-dna.go b/test/bench/regex-dna.go index 2e1ab8edb..9d56830b3 100644 --- a/test/bench/regex-dna.go +++ b/test/bench/regex-dna.go @@ -36,11 +36,11 @@ POSSIBILITY OF SUCH DAMAGE. package main import ( - "fmt"; - "io/ioutil"; - "os"; - "regexp"; - "strings"; + "fmt" + "io/ioutil" + "os" + "regexp" + "strings" ) var variants = []string{ @@ -56,7 +56,7 @@ var variants = []string{ } type Subst struct { - pat, repl string; + pat, repl string } var substs = []Subst{ @@ -74,34 +74,34 @@ var substs = []Subst{ } func countMatches(pat string, bytes []byte) int { - re := regexp.MustCompile(pat); - n := 0; + re := regexp.MustCompile(pat) + n := 0 for { - e := re.Execute(bytes); + e := re.Execute(bytes) if len(e) == 0 { break } - n++; - bytes = bytes[e[1]:]; + n++ + bytes = bytes[e[1]:] } - return n; + return n } func main() { - bytes, err := ioutil.ReadFile("/dev/stdin"); + bytes, err := ioutil.ReadFile("/dev/stdin") if err != nil { - fmt.Fprintf(os.Stderr, "can't read input: %s\n", err); - os.Exit(2); + fmt.Fprintf(os.Stderr, "can't read input: %s\n", err) + os.Exit(2) } - ilen := len(bytes); + ilen := len(bytes) // Delete the comment lines and newlines - bytes = regexp.MustCompile("(>[^\n]+)?\n").ReplaceAll(bytes, []byte{}); - clen := len(bytes); + bytes = regexp.MustCompile("(>[^\n]+)?\n").ReplaceAll(bytes, []byte{}) + clen := len(bytes) for _, s := range variants { fmt.Printf("%s %d\n", s, countMatches(s, bytes)) } for _, sub := range substs { bytes = regexp.MustCompile(sub.pat).ReplaceAll(bytes, strings.Bytes(sub.repl)) } - fmt.Printf("\n%d\n%d\n%d\n", ilen, clen, len(bytes)); + fmt.Printf("\n%d\n%d\n%d\n", ilen, clen, len(bytes)) } -- cgit v1.2.3