From 3061c451d21ff28222dcf93c694bcc69f73e35a4 Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Thu, 1 Apr 2021 17:14:23 +0200 Subject: [PATCH] [dmd-cxx] printf format fixes --- std/format.d | 4 ++-- std/internal/math/biguintcore.d | 4 ++-- std/math.d | 4 ++-- std/zip.d | 6 +++--- unittest.d | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/std/format.d b/std/format.d index 64b1bd30e..17e5906ba 100644 --- a/std/format.d +++ b/std/format.d @@ -5199,7 +5199,7 @@ body } debug (unformatRange) printf("\t"); 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() { @@ -5246,7 +5246,7 @@ body auto sep = spec.sep !is null ? spec.sep : fmt.trailing; 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"); } diff --git a/std/internal/math/biguintcore.d b/std/internal/math/biguintcore.d index f5cd769e7..6fc2d1673 100644 --- a/std/internal/math/biguintcore.d +++ b/std/internal/math/biguintcore.d @@ -2503,13 +2503,13 @@ pure nothrow void printBiguint(const uint [] 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) { auto str = data.toDecimalString(0); - printf("%.*s\n", str.length, str.ptr); + printf("%.*s\n", cast(int) str.length, str.ptr); } uint [] a, b; diff --git a/std/math.d b/std/math.d index 6b6c53571..20ca80626 100644 --- a/std/math.d +++ b/std/math.d @@ -246,8 +246,8 @@ version (unittest) alias real_t = double; else alias real_t = real; - ix = sprintf(bufx.ptr, "%.*Lg", ndigits, cast(real_t) x); - iy = sprintf(bufy.ptr, "%.*Lg", ndigits, cast(real_t) y); + ix = sprintf(bufx.ptr, is(real_t == real) ? "%.*Lg" : "%.*g", ndigits, cast(real_t) x); + iy = sprintf(bufy.ptr, is(real_t == real) ? "%.*Lg" : "%.*g", ndigits, cast(real_t) y); assert(ix < bufx.length && ix > 0); assert(ix < bufy.length && ix > 0); diff --git a/std/zip.d b/std/zip.d index 8b130ea2d..9e55d199a 100644 --- a/std/zip.d +++ b/std/zip.d @@ -263,8 +263,8 @@ final class ArchiveMember { void print() { - printf("name = '%.*s'\n", name.length, name.ptr); - printf("\tcomment = '%.*s'\n", comment.length, comment.ptr); + printf("name = '%.*s'\n", cast(int) name.length, name.ptr); + printf("\tcomment = '%.*s'\n", cast(int) comment.length, comment.ptr); printf("\tmadeVersion = x%04x\n", _madeVersion); printf("\textractVersion = x%04x\n", extractVersion); printf("\tflags = x%04x\n", flags); @@ -348,7 +348,7 @@ final class ZipArchive printf("\tdiskStartDir = %u\n", diskStartDir); printf("\tnumEntries = %u\n", numEntries); printf("\ttotalEntries = %u\n", totalEntries); - printf("\tcomment = '%.*s'\n", comment.length, comment.ptr); + printf("\tcomment = '%.*s'\n", cast(int) comment.length, comment.ptr); } } diff --git a/unittest.d b/unittest.d index ac8e07c84..3e059fabf 100644 --- a/unittest.d +++ b/unittest.d @@ -86,9 +86,9 @@ int main(string[] args) assert(c.re == 2); 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++) - 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; x[0] = 3;