From: Thomas Munro Date: Wed, 19 Nov 2025 21:23:44 +0000 (+1300) Subject: Drop support for MSVCRT's float formatting quirk. X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=6b46669883fac9521c20fe4e2c55ccfbee778591;p=postgresql.git Drop support for MSVCRT's float formatting quirk. Commit f1885386 added code to remove an unnecessary leading zero from the exponent in a float formatted by the system snprintf(). The C standard doesn't allow unnecessary digits beyond two, and the tests pass without this on Windows' modern UCRT (required since commit 1758d424). Discussion: https://postgr.es/m/CA%2BhUKGJnmzTqiODmTjf-23yZ%3DE3HXqFTtKoyp3TF-MpB93hTMQ%40mail.gmail.com --- diff --git a/src/port/snprintf.c b/src/port/snprintf.c index dded6c3f65b..6541182df6d 100644 --- a/src/port/snprintf.c +++ b/src/port/snprintf.c @@ -1205,22 +1205,6 @@ fmtfloat(double value, char type, int forcesign, int leftjust, } if (vallen < 0) goto fail; - - /* - * Windows, alone among our supported platforms, likes to emit - * three-digit exponent fields even when two digits would do. Hack - * such results to look like the way everyone else does it. - */ -#ifdef WIN32 - if (vallen >= 6 && - convert[vallen - 5] == 'e' && - convert[vallen - 3] == '0') - { - convert[vallen - 3] = convert[vallen - 2]; - convert[vallen - 2] = convert[vallen - 1]; - vallen--; - } -#endif } padlen = compute_padlen(minlen, vallen + zeropadlen, leftjust); @@ -1336,17 +1320,6 @@ pg_strfromd(char *str, size_t count, int precision, double value) target.failed = true; goto fail; } - -#ifdef WIN32 - if (vallen >= 6 && - convert[vallen - 5] == 'e' && - convert[vallen - 3] == '0') - { - convert[vallen - 3] = convert[vallen - 2]; - convert[vallen - 2] = convert[vallen - 1]; - vallen--; - } -#endif } }