suppress-windows-leading-zero-in-float-exponents.patch
text/x-diff
Filename: suppress-windows-leading-zero-in-float-exponents.patch
Type: text/x-diff
Part: 0
Patch
Format: unified
| File | + | − |
|---|---|---|
| src/port/snprintf.c | 27 | 0 |
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 58300ea..0eb70c2 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -1173,6 +1173,22 @@ 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);
@@ -1290,6 +1306,17 @@ 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
}
}