Commit 2b755564 authored by Ken Thompson's avatar Ken Thompson

export large constants

R=r
DELTA=37  (31 added, 4 deleted, 2 changed)
OCL=14089
CL=14089
parent cbaca0be
......@@ -78,7 +78,7 @@ dumpexportconst(Sym *s)
case CTINT:
case CTSINT:
case CTUINT:
Bprint(bout, "0x%llux\n", mpgetfix(n->val.u.xval));
Bprint(bout, "%B\n", n->val.u.xval);
break;
case CTBOOL:
Bprint(bout, "0x%llux\n", n->val.u.bval);
......
......@@ -487,6 +487,7 @@ void mpatofix(Mpint *a, char *s);
void mpatoflt(Mpflt *a, char *s);
void mpmovefltfix(Mpint *a, Mpflt *b);
void mpmovefixflt(Mpflt *a, Mpint *b);
int Bconv(Fmt*);
/*
* mparith2.c
......
......@@ -52,6 +52,7 @@ mainlex(int argc, char *argv[])
fmtinstall('N', Nconv); // node pointer
fmtinstall('Z', Zconv); // escaped string
fmtinstall('L', Lconv); // line number
fmtinstall('B', Bconv); // big numbers
lexinit();
lineno = 1;
......
......@@ -348,3 +348,32 @@ bad:
warn("set ovf in mpatov: %s", as);
mpmovecfix(a, 0);
}
int
Bconv(Fmt *fp)
{
char buf[500], *p;
Mpint *xval, q, r, ten;
int f;
xval = va_arg(fp->args, Mpint*);
mpmovefixfix(&q, xval);
f = 0;
if(mptestfix(&q) < 0) {
f = 1;
mpnegfix(&q);
}
mpmovecfix(&ten, 10);
p = &buf[sizeof(buf)];
*--p = 0;
for(;;) {
mpdivmodfixfix(&q, &r, &q, &ten);
*--p = mpgetfix(&r) + '0';
if(mptestfix(&q) <= 0)
break;
}
if(f)
*--p = '-';
return fmtstrcpy(fp, p);
}
......@@ -1053,13 +1053,9 @@ Nconv(Fmt *fp)
snprint(buf1, sizeof(buf1), "LITERAL-ctype=%d", n->val.ctype);
break;
case CTINT:
snprint(buf1, sizeof(buf1), "I%lld", mpgetfix(n->val.u.xval));
break;
case CTSINT:
snprint(buf1, sizeof(buf1), "S%lld", mpgetfix(n->val.u.xval));
break;
case CTUINT:
snprint(buf1, sizeof(buf1), "U%lld", mpgetfix(n->val.u.xval));
snprint(buf1, sizeof(buf1), "I%B", n->val.u.xval);
break;
case CTFLT:
snprint(buf1, sizeof(buf1), "F%g", mpgetflt(n->val.u.fval));
......
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