1
0
mirror of https://github.com/golang/go synced 2024-11-22 02:04:40 -07:00

godefs: guard against structs with pad fields

Fixes #1162.

R=r
CC=golang-dev
https://golang.org/cl/3619041
This commit is contained in:
Russ Cox 2010-12-13 15:50:47 -05:00
parent 9e26c4bd1a
commit 318c1eeb32

View File

@ -133,7 +133,7 @@ Lang go =
"type %s struct {\n", "type %s struct {\n",
"type %s struct {\n", "type %s struct {\n",
"\tPad%d [%d]byte;\n", "\tPad_godefs_%d [%d]byte;\n",
"}\n", "}\n",
gotypefmt, gotypefmt,
@ -150,7 +150,7 @@ Lang c =
"typedef struct %s %s;\nstruct %s {\n", "typedef struct %s %s;\nstruct %s {\n",
"typedef union %s %s;\nunion %s {\n", "typedef union %s %s;\nunion %s {\n",
"\tbyte pad%d[%d];\n", "\tbyte pad_godefs_%d[%d];\n",
"};\n", "};\n",
ctypefmt, ctypefmt,
@ -391,7 +391,7 @@ Continue:
if(cutprefix(name)) if(cutprefix(name))
name += prefix; name += prefix;
if(strcmp(name, "") == 0) { if(strcmp(name, "") == 0) {
snprint(nambuf, sizeof nambuf, "Pad%d", npad++); snprint(nambuf, sizeof nambuf, "Pad_godefs_%d", npad++);
name = nambuf; name = nambuf;
} }
Bprint(bout, "\t%#lT;\n", name, f->type); Bprint(bout, "\t%#lT;\n", name, f->type);