]> Cypherpunks repositories - gostls13.git/commitdiff
godefs: fix handling of negative constants
authorRuss Cox <rsc@golang.org>
Tue, 30 Mar 2010 17:42:13 +0000 (10:42 -0700)
committerRuss Cox <rsc@golang.org>
Tue, 30 Mar 2010 17:42:13 +0000 (10:42 -0700)
R=r
CC=golang-dev
https://golang.org/cl/849041

src/cmd/godefs/main.c

index 3735167d2466b57b3b41c54aabee6364982b2c6c..6ff542f4897d046c8c2716417eb95ed343e10c19 100644 (file)
@@ -294,8 +294,14 @@ Continue:
        Bprint(bout, "// Constants\n");
        if(ncon > 0) {
                Bprint(bout, lang->constbegin);
-               for(i=0; i<ncon; i++)
-                       Bprint(bout, lang->constfmt, con[i].name, con[i].value & 0xFFFFFFFF);
+               for(i=0; i<ncon; i++) {
+                       // Go can handle negative constants,
+                       // but C enums may not be able to.
+                       if(lang == &go)
+                               Bprint(bout, lang->constfmt, con[i].name, con[i].value);
+                       else
+                               Bprint(bout, lang->constfmt, con[i].name, con[i].value & 0xFFFFFFFF);
+               }
                Bprint(bout, lang->constend);
        }
        Bprint(bout, "\n");