0002-Drop-support-for-MSVCRT-s-float-formatting-quirk.patch
text/x-patch
Filename: 0002-Drop-support-for-MSVCRT-s-float-formatting-quirk.patch
Type: text/x-patch
Part: 1
Message:
Re: PRI?64 vs Visual Studio (2022)
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0002
Subject: Drop support for MSVCRT's float formatting quirk.
| File | + | − |
|---|---|---|
| src/port/snprintf.c | 0 | 27 |
From 368a43f169a92c9ec172f229a650f7dd6acf97a1 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Wed, 19 Nov 2025 14:25:42 +1300
Subject: [PATCH 2/2] 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 kludge on modern UCRT-based Windows systems.
---
src/port/snprintf.c | 27 ---------------------------
1 file changed, 27 deletions(-)
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
}
}
--
2.51.2