[dmd-cxx] printf format fixes

This commit is contained in:
Walter Bright 2021-04-01 17:14:23 +02:00 committed by Nicholas Wilson
parent 5ccd697c3f
commit 3061c451d2
5 changed files with 11 additions and 11 deletions

View file

@ -5199,7 +5199,7 @@ body
} }
debug (unformatRange) printf("\t"); debug (unformatRange) printf("\t");
debug (unformatRange) if (!input.empty) printf("input.front = %c, ", input.front); debug (unformatRange) if (!input.empty) printf("input.front = %c, ", input.front);
debug (unformatRange) printf("cont = %.*s\n", cont); debug (unformatRange) printf("cont = %.*s\n", cast(int) cont.length, cont.ptr);
bool checkEnd() bool checkEnd()
{ {
@ -5246,7 +5246,7 @@ body
auto sep = spec.sep !is null ? spec.sep auto sep = spec.sep !is null ? spec.sep
: fmt.trailing; : fmt.trailing;
debug (unformatRange) { debug (unformatRange) {
if (!sep.empty && !input.empty) printf("-> %c, sep = %.*s\n", input.front, sep); if (!sep.empty && !input.empty) printf("-> %c, sep = %.*s\n", input.front, cast(int) sep.length, sep.ptr);
else printf("\n"); else printf("\n");
} }

View file

@ -2503,13 +2503,13 @@ pure nothrow
void printBiguint(const uint [] data) void printBiguint(const uint [] data)
{ {
char [] buff = biguintToHex(new char[data.length*9], data, '_'); char [] buff = biguintToHex(new char[data.length*9], data, '_');
printf("%.*s\n", buff.length, buff.ptr); printf("%.*s\n", cast(int) buff.length, buff.ptr);
} }
void printDecimalBigUint(BigUint data) void printDecimalBigUint(BigUint data)
{ {
auto str = data.toDecimalString(0); auto str = data.toDecimalString(0);
printf("%.*s\n", str.length, str.ptr); printf("%.*s\n", cast(int) str.length, str.ptr);
} }
uint [] a, b; uint [] a, b;

View file

@ -246,8 +246,8 @@ version (unittest)
alias real_t = double; alias real_t = double;
else else
alias real_t = real; alias real_t = real;
ix = sprintf(bufx.ptr, "%.*Lg", ndigits, cast(real_t) x); ix = sprintf(bufx.ptr, is(real_t == real) ? "%.*Lg" : "%.*g", ndigits, cast(real_t) x);
iy = sprintf(bufy.ptr, "%.*Lg", ndigits, cast(real_t) y); iy = sprintf(bufy.ptr, is(real_t == real) ? "%.*Lg" : "%.*g", ndigits, cast(real_t) y);
assert(ix < bufx.length && ix > 0); assert(ix < bufx.length && ix > 0);
assert(ix < bufy.length && ix > 0); assert(ix < bufy.length && ix > 0);

View file

@ -263,8 +263,8 @@ final class ArchiveMember
{ {
void print() void print()
{ {
printf("name = '%.*s'\n", name.length, name.ptr); printf("name = '%.*s'\n", cast(int) name.length, name.ptr);
printf("\tcomment = '%.*s'\n", comment.length, comment.ptr); printf("\tcomment = '%.*s'\n", cast(int) comment.length, comment.ptr);
printf("\tmadeVersion = x%04x\n", _madeVersion); printf("\tmadeVersion = x%04x\n", _madeVersion);
printf("\textractVersion = x%04x\n", extractVersion); printf("\textractVersion = x%04x\n", extractVersion);
printf("\tflags = x%04x\n", flags); printf("\tflags = x%04x\n", flags);
@ -348,7 +348,7 @@ final class ZipArchive
printf("\tdiskStartDir = %u\n", diskStartDir); printf("\tdiskStartDir = %u\n", diskStartDir);
printf("\tnumEntries = %u\n", numEntries); printf("\tnumEntries = %u\n", numEntries);
printf("\ttotalEntries = %u\n", totalEntries); printf("\ttotalEntries = %u\n", totalEntries);
printf("\tcomment = '%.*s'\n", comment.length, comment.ptr); printf("\tcomment = '%.*s'\n", cast(int) comment.length, comment.ptr);
} }
} }

View file

@ -86,9 +86,9 @@ int main(string[] args)
assert(c.re == 2); assert(c.re == 2);
assert(c.im == 1); assert(c.im == 1);
printf("args.length = %d\n", args.length); printf("args.length = %d\n", cast(int)args.length);
for (int i = 0; i < args.length; i++) for (int i = 0; i < args.length; i++)
printf("args[%d] = '%.*s'\n", i, args[i].length, args[i].ptr); printf("args[%d] = '%.*s'\n", i, cast(int)args[i].length, args[i].ptr);
int[3] x; int[3] x;
x[0] = 3; x[0] = 3;