1
0
mirror of https://github.com/golang/go synced 2024-11-26 06:07:57 -07:00

update fmt to use some initialization

tweak ar so the pkgdef file doesn't cause it not to generate a symbol table

SVN=128119
This commit is contained in:
Rob Pike 2008-07-19 14:52:01 -07:00
parent c92aff2de7
commit acf3d59847
2 changed files with 14 additions and 16 deletions

View File

@ -111,6 +111,7 @@ char artemp[] = "/tmp/vXXXXX";
char movtemp[] = "/tmp/v1XXXXX"; char movtemp[] = "/tmp/v1XXXXX";
char tailtemp[] = "/tmp/v2XXXXX"; char tailtemp[] = "/tmp/v2XXXXX";
char symdef[] = "__.SYMDEF"; char symdef[] = "__.SYMDEF";
char pkgdef[] = "__.PKGDEF";
int aflag; /* command line flags */ int aflag; /* command line flags */
int bflag; int bflag;
@ -566,6 +567,7 @@ scanobj(Biobuf *b, Arfile *ap, long size)
offset = Boffset(b); offset = Boffset(b);
obj = objtype(b, 0); obj = objtype(b, 0);
if (obj < 0) { /* not an object file */ if (obj < 0) { /* not an object file */
if (strcmp(file, pkgdef) != 0) /* don't clear allobj if it's pkg defs */
allobj = 0; allobj = 0;
d = dirfstat(Bfildes(b)); d = dirfstat(Bfildes(b));
if (d != nil && d->length == 0) if (d != nil && d->length == 0)

View File

@ -18,11 +18,19 @@ export Fmt, New;
const NByte = 64; const NByte = 64;
const NPows10 = 160; // BUG: why not nelem(pows10); const NPows10 = 160; // BUG: why not nelem(pows10);
var ldigits string; var ldigits string = "0123456789abcdef"; // BUG: Should be const
var udigits string; var udigits string = "0123456789ABCDEF"; // BUG: Should be const
var inited bool;
var pows10 [NPows10] double; var pows10 [NPows10] double;
func init() {
pows10[0] = 1.0e0;
pows10[1] = 1.0e1;
for i:=2; i<NPows10; i++ {
m := i/2;
pows10[i] = pows10[m] * pows10[i-m];
}
}
type Fmt struct { type Fmt struct {
buf string; buf string;
wid int; wid int;
@ -43,18 +51,6 @@ func (f *Fmt) clearbuf() {
func (f *Fmt) init() { func (f *Fmt) init() {
f.clearbuf(); f.clearbuf();
f.clearflags(); f.clearflags();
if inited {
return;
}
ldigits = "0123456789abcdef"; // BUG: should be initialized const
udigits = "0123456789ABCDEF"; // BUG: should be initialized const
// BUG: should be done with initialization
var p double = 1.0;
for i := 0; i < NPows10; i++ {
pows10[i] = p;
p *= 10.0;
}
inited = true;
} }
func New() *Fmt { func New() *Fmt {