]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: do not output empty struct for -cdefs
authorAlex Brainman <alex.brainman@gmail.com>
Sat, 25 May 2013 10:53:55 +0000 (20:53 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Sat, 25 May 2013 10:53:55 +0000 (20:53 +1000)
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9574043

src/cmd/cgo/godefs.go

index 20376170dafd975654902f4a632a9e361ac792fc..3dfedcb282fe99c7ebe496244ea29fabf2f8318a 100644 (file)
@@ -204,6 +204,11 @@ func (p *Package) cdefs(f *File, srcfile string) string {
                //              byte Z[4];
                //      }
                if strings.HasPrefix(line, "type ") && strings.HasSuffix(line, " struct {") {
+                       if len(lines) > i+1 && lines[i+1] == "}" {
+                               // do not output empty struct
+                               i++
+                               continue
+                       }
                        s := line[len("type ") : len(line)-len(" struct {")]
                        printf("struct %s {\n", s)
                        for i++; i < len(lines) && lines[i] != "}"; i++ {