Commit 6fff0efd authored by Ken Thompson's avatar Ken Thompson

sprint changed to snprint

R=r
OCL=18316
CL=18316
parent db27d309
...@@ -52,27 +52,27 @@ Pconv(Fmt *fp) ...@@ -52,27 +52,27 @@ Pconv(Fmt *fp)
p = va_arg(fp->args, Prog*); p = va_arg(fp->args, Prog*);
bigP = p; bigP = p;
sprint(str1, "(%ld)", p->line); snprint(str1, sizeof(str1), "(%ld)", p->line);
switch(p->as) { switch(p->as) {
case ATEXT: case ATEXT:
if(p->from.scale) { if(p->from.scale) {
sprint(str, "%-7s %-7A %D,%d,%lD", snprint(str, sizeof(str), "%-7s %-7A %D,%d,%lD",
str1, p->as, &p->from, p->from.scale, &p->to); str1, p->as, &p->from, p->from.scale, &p->to);
break; break;
} }
sprint(str, "%-7s %-7A %D,%lD", snprint(str, sizeof(str), "%-7s %-7A %D,%lD",
str1, p->as, &p->from, &p->to); str1, p->as, &p->from, &p->to);
break; break;
default: default:
sprint(str, "%-7s %-7A %D,%D", snprint(str, sizeof(str), "%-7s %-7A %D,%D",
str1, p->as, &p->from, &p->to); str1, p->as, &p->from, &p->to);
break; break;
case ADATA: case ADATA:
case AINIT: case AINIT:
case ADYNT: case ADYNT:
sprint(str, "%-7s %-7A %D/%d,%D", snprint(str, sizeof(str), "%-7s %-7A %D/%d,%D",
str1, p->as, &p->from, p->from.scale, &p->to); str1, p->as, &p->from, p->from.scale, &p->to);
break; break;
} }
...@@ -102,32 +102,32 @@ Dconv(Fmt *fp) ...@@ -102,32 +102,32 @@ Dconv(Fmt *fp)
if(fp->flags & FmtLong) { if(fp->flags & FmtLong) {
if(i != D_CONST) { if(i != D_CONST) {
// ATEXT dst is not constant // ATEXT dst is not constant
sprint(str, "!!%D", a); snprint(str, sizeof(str), "!!%D", a);
goto brk; goto brk;
} }
parsetextconst(a->offset); parsetextconst(a->offset);
if(textarg == 0) { if(textarg == 0) {
sprint(str, "$%lld", textstksiz); snprint(str, sizeof(str), "$%lld", textstksiz);
goto brk; goto brk;
} }
sprint(str, "$%lld-%lld", textstksiz, textarg); snprint(str, sizeof(str), "$%lld-%lld", textstksiz, textarg);
goto brk; goto brk;
} }
if(i >= D_INDIR) { if(i >= D_INDIR) {
if(a->offset) if(a->offset)
sprint(str, "%lld(%R)", a->offset, i-D_INDIR); snprint(str, sizeof(str), "%lld(%R)", a->offset, i-D_INDIR);
else else
sprint(str, "(%R)", i-D_INDIR); snprint(str, sizeof(str), "(%R)", i-D_INDIR);
goto brk; goto brk;
} }
switch(i) { switch(i) {
default: default:
if(a->offset) if(a->offset)
sprint(str, "$%lld,%R", a->offset, i); snprint(str, sizeof(str), "$%lld,%R", a->offset, i);
else else
sprint(str, "%R", i); snprint(str, sizeof(str), "%R", i);
break; break;
case D_NONE: case D_NONE:
...@@ -137,70 +137,70 @@ Dconv(Fmt *fp) ...@@ -137,70 +137,70 @@ Dconv(Fmt *fp)
case D_BRANCH: case D_BRANCH:
if(bigP != P && bigP->pcond != P) if(bigP != P && bigP->pcond != P)
if(a->sym != S) if(a->sym != S)
sprint(str, "%llux+%s", bigP->pcond->pc, snprint(str, sizeof(str), "%llux+%s", bigP->pcond->pc,
a->sym->name); a->sym->name);
else else
sprint(str, "%llux", bigP->pcond->pc); snprint(str, sizeof(str), "%llux", bigP->pcond->pc);
else else
sprint(str, "%lld(PC)", a->offset); snprint(str, sizeof(str), "%lld(PC)", a->offset);
break; break;
case D_EXTERN: case D_EXTERN:
if(a->sym) { if(a->sym) {
sprint(str, "%s+%lld(SB)", a->sym->name, a->offset); snprint(str, sizeof(str), "%s+%lld(SB)", a->sym->name, a->offset);
break; break;
} }
sprint(str, "!!noname!!+%lld(SB)", a->offset); snprint(str, sizeof(str), "!!noname!!+%lld(SB)", a->offset);
break; break;
case D_STATIC: case D_STATIC:
if(a->sym) { if(a->sym) {
sprint(str, "%s<%d>+%lld(SB)", a->sym->name, snprint(str, sizeof(str), "%s<%d>+%lld(SB)", a->sym->name,
a->sym->version, a->offset); a->sym->version, a->offset);
break; break;
} }
sprint(str, "!!noname!!<999>+%lld(SB)", a->offset); snprint(str, sizeof(str), "!!noname!!<999>+%lld(SB)", a->offset);
break; break;
case D_AUTO: case D_AUTO:
if(a->sym) { if(a->sym) {
sprint(str, "%s+%lld(SP)", a->sym->name, a->offset); snprint(str, sizeof(str), "%s+%lld(SP)", a->sym->name, a->offset);
break; break;
} }
sprint(str, "!!noname!!+%lld(SP)", a->offset); snprint(str, sizeof(str), "!!noname!!+%lld(SP)", a->offset);
break; break;
case D_PARAM: case D_PARAM:
if(a->sym) { if(a->sym) {
sprint(str, "%s+%lld(%s)", a->sym->name, a->offset, paramspace); snprint(str, sizeof(str), "%s+%lld(%s)", a->sym->name, a->offset, paramspace);
break; break;
} }
sprint(str, "!!noname!!+%lld(%s)", a->offset, paramspace); snprint(str, sizeof(str), "!!noname!!+%lld(%s)", a->offset, paramspace);
break; break;
case D_CONST: case D_CONST:
sprint(str, "$%lld", a->offset); snprint(str, sizeof(str), "$%lld", a->offset);
break; break;
case D_FCONST: case D_FCONST:
sprint(str, "$(%.8lux,%.8lux)", a->ieee.h, a->ieee.l); snprint(str, sizeof(str), "$(%.8lux,%.8lux)", a->ieee.h, a->ieee.l);
break; break;
case D_SCONST: case D_SCONST:
sprint(str, "$\"%S\"", a->scon); snprint(str, sizeof(str), "$\"%S\"", a->scon);
break; break;
case D_ADDR: case D_ADDR:
a->type = a->index; a->type = a->index;
a->index = D_NONE; a->index = D_NONE;
sprint(str, "$%D", a); snprint(str, sizeof(str), "$%D", a);
a->index = a->type; a->index = a->type;
a->type = D_ADDR; a->type = D_ADDR;
goto conv; goto conv;
} }
brk: brk:
if(a->index != D_NONE) { if(a->index != D_NONE) {
sprint(s, "(%R*%d)", a->index, a->scale); snprint(s, sizeof(s), "(%R*%d)", a->index, a->scale);
strcat(str, s); strcat(str, s);
} }
conv: conv:
...@@ -342,9 +342,9 @@ Rconv(Fmt *fp) ...@@ -342,9 +342,9 @@ Rconv(Fmt *fp)
r = va_arg(fp->args, int); r = va_arg(fp->args, int);
if(r >= D_AL && r <= D_NONE) if(r >= D_AL && r <= D_NONE)
sprint(str, "%s", regstr[r-D_AL]); snprint(str, sizeof(str), "%s", regstr[r-D_AL]);
else else
sprint(str, "gok(%d)", r); snprint(str, sizeof(str), "gok(%d)", r);
return fmtstrcpy(fp, str); return fmtstrcpy(fp, str);
} }
......
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