c99 printf/fprintf compliance.

This commit is contained in:
Keith Kanios 2007-04-14 00:10:59 +00:00
parent 0899e21289
commit 93f2e9a5a1
9 changed files with 39 additions and 40 deletions

View File

@ -102,7 +102,7 @@ static ListGen *list;
static int32_t calcsize(int32_t, int32_t, int, insn *, const char *);
static void gencode(int32_t, int32_t, int, insn *, const char *, int32_t);
static int regval(operand * o);
static int regflag(operand * o);
// static int regflag(operand * o);
static int matches(struct itemplate *, insn *, int bits);
static ea *process_ea(operand *, ea *, int, int, int);
static int chsize(operand *, int);

View File

@ -789,11 +789,11 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
snprintf(output + slen, outbufsize - slen, "short ");
}
slen +=
snprintf(output + slen, outbufsize - slen, "0x%lx",
snprintf(output + slen, outbufsize - slen, "0x%"PRIx64"",
ins.oprs[i].offset);
} else if (!(MEM_OFFS & ~(*p)->opd[i])) {
slen +=
snprintf(output + slen, outbufsize - slen, "[%s%s%s0x%lx]",
snprintf(output + slen, outbufsize - slen, "[%s%s%s0x%"PRIx64"]",
((const char*)segover ? (const char*)segover : ""), /* placate type mistmatch warning */
((const char*)segover ? ":" : ""), /* by using (const char*) instead of uint8_t* */
(ins.oprs[i].addr_size ==
@ -859,19 +859,19 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
sign = '-';
}
slen +=
snprintf(output + slen, outbufsize - slen, "%c0x%lx",
snprintf(output + slen, outbufsize - slen, "%c0x%"PRIx64"",
sign, ins.oprs[i].offset);
} else if (ins.oprs[i].segment & SEG_DISP16) {
if (started)
output[slen++] = '+';
slen +=
snprintf(output + slen, outbufsize - slen, "0x%lx",
snprintf(output + slen, outbufsize - slen, "0x%"PRIx64"",
ins.oprs[i].offset);
} else if (ins.oprs[i].segment & SEG_DISP32) {
if (started)
output[slen++] = '+';
slen +=
snprintf(output + slen, outbufsize - slen, "0x%lx",
snprintf(output + slen, outbufsize - slen, "0x%"PRIx64"",
ins.oprs[i].offset);
}
output[slen++] = ']';

View File

@ -56,10 +56,10 @@ static void list_emit(void)
if (!listlinep && !listdata[0])
return;
fprintf(listfp, "%6ld ", ++listlineno);
fprintf(listfp, "%6"PRId32" ", ++listlineno);
if (listdata[0])
fprintf(listfp, "%08lX %-*s", listoffset, LIST_HEXBIT + 1,
fprintf(listfp, "%08"PRIX32" %-*s", listoffset, LIST_HEXBIT + 1,
listdata);
else
fprintf(listfp, "%*s", LIST_HEXBIT + 10, "");
@ -206,7 +206,7 @@ static void list_output(int32_t offset, const void *data, uint32_t type)
list_out(offset, q);
} else if (typ == OUT_RESERVE) {
char q[20];
snprintf(q, sizeof(q), "<res %08lX>", size);
snprintf(q, sizeof(q), "<res %08"PRIX32">", size);
list_out(offset, q);
}
}

8
nasm.c
View File

@ -241,7 +241,7 @@ int main(int argc, char **argv)
else {
lineinc = (altline != -1 || lineinc != 1);
fprintf(ofile ? ofile : stdout,
"%%line %ld+%d %s\n", linnum, lineinc,
"%%line %"PRId32"+%d %s\n", linnum, lineinc,
file_name);
}
prior_linnum = linnum;
@ -1438,7 +1438,7 @@ static void report_error_gnu(int severity, const char *fmt, ...)
char *currentfile = NULL;
int32_t lineno = 0;
src_get(&lineno, &currentfile);
fprintf(error_file, "%s:%ld: ", currentfile, lineno);
fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno);
nasm_free(currentfile);
}
va_start(ap, fmt);
@ -1474,7 +1474,7 @@ static void report_error_vc(int severity, const char *fmt, ...)
char *currentfile = NULL;
int32_t lineno = 0;
src_get(&lineno, &currentfile);
fprintf(error_file, "%s(%ld) : ", currentfile, lineno);
fprintf(error_file, "%s(%"PRId32") : ", currentfile, lineno);
nasm_free(currentfile);
}
va_start(ap, fmt);
@ -1643,7 +1643,7 @@ static char *no_pp_getline(void)
int32_t ln;
int li;
char *nm = nasm_malloc(strlen(buffer));
if (sscanf(buffer + 5, "%ld+%d %s", &ln, &li, nm) == 3) {
if (sscanf(buffer + 5, "%"PRId32"+%d %s", &ln, &li, nm) == 3) {
nasm_free(src_set_fname(nm));
src_set_linnum(ln);
no_pp_lineinc = li;

View File

@ -254,8 +254,7 @@ int main(int argc, char **argv)
p += lenread;
if ((uint32_t)offset == nextsync) {
if (synclen) {
fprintf(stdout, "%08lX skipping 0x%lX bytes\n", offset,
synclen);
fprintf(stdout, "%08"PRIX32" skipping 0x%"PRIX32" bytes\n", offset, synclen);
offset += synclen;
skip(synclen, fp);
}
@ -293,7 +292,7 @@ static void output_ins(uint32_t offset, uint8_t *data,
int datalen, char *insn)
{
int bytes;
fprintf(stdout, "%08lX ", offset);
fprintf(stdout, "%08"PRIX32" ", offset);
bytes = 0;
while (datalen > 0 && bytes < BPL) {

View File

@ -596,7 +596,7 @@ static void bin_cleanup(int debuginfo)
fprintf(rf, "-- Program origin ");
for (h = 61; h; h--)
fputc('-', rf);
fprintf(rf, "\n\n%08lX\n\n", origin);
fprintf(rf, "\n\n%08"PRIX32"\n\n", origin);
}
/* Display sections summary. */
if (map_control & MAP_SUMMARY) {
@ -606,7 +606,7 @@ static void bin_cleanup(int debuginfo)
fprintf(rf, "\n\nVstart Start Stop "
"Length Class Name\n");
for (s = sections; s; s = s->next) {
fprintf(rf, "%08lX %08lX %08lX %08lX ",
fprintf(rf, "%08"PRIX32" %08"PRIX32" %08"PRIX32" %08"PRIX32" ",
s->vstart, s->start, s->start + s->length,
s->length);
if (s->flags & TYPE_PROGBITS)
@ -632,10 +632,10 @@ static void bin_cleanup(int debuginfo)
fprintf(rf, "progbits");
else
fprintf(rf, "nobits");
fprintf(rf, "\nlength: %08lX\nstart: %08lX"
fprintf(rf, "\nlength: %08"PRIX32"\nstart: %08"PRIX32""
"\nalign: ", s->length, s->start);
if (s->flags & ALIGN_DEFINED)
fprintf(rf, "%08lX", s->align);
fprintf(rf, "%08"PRIX32"", s->align);
else
fprintf(rf, not_defined);
fprintf(rf, "\nfollows: ");
@ -643,9 +643,9 @@ static void bin_cleanup(int debuginfo)
fprintf(rf, "%s", s->follows);
else
fprintf(rf, not_defined);
fprintf(rf, "\nvstart: %08lX\nvalign: ", s->vstart);
fprintf(rf, "\nvstart: %08"PRIX32"\nvalign: ", s->vstart);
if (s->flags & VALIGN_DEFINED)
fprintf(rf, "%08lX", s->valign);
fprintf(rf, "%08"PRIX32"", s->valign);
else
fprintf(rf, not_defined);
fprintf(rf, "\nvfollows: ");
@ -671,7 +671,7 @@ static void bin_cleanup(int debuginfo)
fprintf(rf, "\n\nValue Name\n");
for (l = no_seg_labels; l; l = l->next) {
lookup_label(l->name, &segment, &offset);
fprintf(rf, "%08lX %s\n", offset, l->name);
fprintf(rf, "%08"PRIX32" %s\n", offset, l->name);
}
fprintf(rf, "\n\n");
}
@ -683,7 +683,7 @@ static void bin_cleanup(int debuginfo)
fprintf(rf, "\n\nReal Virtual Name\n");
for (l = s->labels; l; l = l->next) {
lookup_label(l->name, &segment, &offset);
fprintf(rf, "%08lX %08lX %s\n",
fprintf(rf, "%08"PRIX32" %08"PRIX32" %s\n",
s->start + offset, s->vstart + offset,
l->name);
}

View File

@ -1194,47 +1194,47 @@ static int32_t ieee_putlr(struct ieeeFixupp *p)
switch (p->ftype) {
case FT_SEG:
if (p->id1 < 0)
sprintf(buf, "%lX", -p->id1);
sprintf(buf, "%"PRIX32"", -p->id1);
else
sprintf(buf, "L%lX,10,/", p->id1);
sprintf(buf, "L%"PRIX32",10,/", p->id1);
break;
case FT_OFS:
sprintf(buf, "R%lX,%lX,+", p->id1, p->addend);
sprintf(buf, "R%"PRIX32",%"PRIX32",+", p->id1, p->addend);
break;
case FT_REL:
sprintf(buf, "R%lX,%lX,+,P,-,%X,-", p->id1, p->addend, p->size);
sprintf(buf, "R%"PRIX32",%"PRIX32",+,P,-,%X,-", p->id1, p->addend, p->size);
break;
case FT_WRT:
if (p->id2 < 0)
sprintf(buf, "R%lX,%lX,+,L%lX,+,%lX,-", p->id2, p->addend,
sprintf(buf, "R%"PRIX32",%"PRIX32",+,L%"PRIX32",+,%"PRIX32",-", p->id2, p->addend,
p->id2, -p->id1 * 16);
else
sprintf(buf, "R%lX,%lX,+,L%lX,+,L%lX,-", p->id2, p->addend,
sprintf(buf, "R%"PRIX32",%"PRIX32",+,L%"PRIX32",+,L%"PRIX32",-", p->id2, p->addend,
p->id2, p->id1);
break;
case FT_EXT:
sprintf(buf, "X%lX", p->id1);
sprintf(buf, "X%"PRIX32"", p->id1);
break;
case FT_EXTREL:
sprintf(buf, "X%lX,P,-,%lX,-", p->id1, size);
sprintf(buf, "X%"PRIX32",P,-,%"PRIX32",-", p->id1, size);
break;
case FT_EXTSEG:
/* We needed a non-ieee hack here.
* We introduce the Y variable, which is the low
* limit of the native segment the extern resides in
*/
sprintf(buf, "Y%lX,10,/", p->id1);
sprintf(buf, "Y%"PRIX32",10,/", p->id1);
break;
case FT_EXTWRT:
if (p->id2 < 0)
sprintf(buf, "X%lX,Y%lX,+,%lX,-", p->id2, p->id2,
sprintf(buf, "X%"PRIX32",Y%"PRIX32",+,%"PRIX32",-", p->id2, p->id2,
-p->id1 * 16);
else
sprintf(buf, "X%lX,Y%lX,+,L%lX,-", p->id2, p->id2, p->id1);
sprintf(buf, "X%"PRIX32",Y%"PRIX32",+,L%"PRIX32",-", p->id2, p->id2, p->id1);
break;
}
ieee_putascii("LR(%s,%lX).\r\n", buf, size);
ieee_putascii("LR(%s,%"PRIX32").\r\n", buf, size);
return (size);
}

View File

@ -1283,7 +1283,7 @@ static void macho_cleanup(int debuginfo)
static void debug_reloc (struct reloc *r)
{
fprintf (stdout, "reloc:\n");
fprintf (stdout, "\taddr: %ld\n", r->addr);
fprintf (stdout, "\taddr: %"PRId32"\n", r->addr);
fprintf (stdout, "\tsnum: %d\n", r->snum);
fprintf (stdout, "\tpcrel: %d\n", r->pcrel);
fprintf (stdout, "\tlength: %d\n", r->length);

View File

@ -968,7 +968,7 @@ static char *detoken(Token * tlist, int expand_locals)
char *p, *q = t->text + 2;
q += strspn(q, "$");
snprintf(buffer, sizeof(buffer), "..@%lu.", ctx->number);
snprintf(buffer, sizeof(buffer), "..@%"PRIu32".", ctx->number);
p = nasm_strcat(buffer, q);
nasm_free(t->text);
t->text = p;
@ -2897,7 +2897,7 @@ static Token *expand_mmac_params(Token * tline)
break;
case '%':
type = TOK_ID;
snprintf(tmpbuf, sizeof(tmpbuf), "..@%lu.",
snprintf(tmpbuf, sizeof(tmpbuf), "..@%"PRIu32".",
mac->unique);
text = nasm_strcat(tmpbuf, t->text + 2);
break;
@ -4138,7 +4138,7 @@ void pp_extra_stdmac(const char **macros)
static void make_tok_num(Token * tok, int32_t val)
{
char numbuf[20];
snprintf(numbuf, sizeof(numbuf), "%ld", val);
snprintf(numbuf, sizeof(numbuf), "%"PRId32"", val);
tok->text = nasm_strdup(numbuf);
tok->type = TOK_NUMBER;
}