Commit a2ec8abd authored by Alex Brainman's avatar Alex Brainman

cmd/cgo: do not output empty struct for -cdefs

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9574043
parent 7472ce0e
...@@ -204,6 +204,11 @@ func (p *Package) cdefs(f *File, srcfile string) string { ...@@ -204,6 +204,11 @@ func (p *Package) cdefs(f *File, srcfile string) string {
// byte Z[4]; // byte Z[4];
// } // }
if strings.HasPrefix(line, "type ") && strings.HasSuffix(line, " struct {") { 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 {")] s := line[len("type ") : len(line)-len(" struct {")]
printf("struct %s {\n", s) printf("struct %s {\n", s)
for i++; i < len(lines) && lines[i] != "}"; i++ { for i++; i < len(lines) && lines[i] != "}"; i++ {
......
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