aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-11-10 10:23:49 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2022-11-10 10:23:49 -0500
commitcf0f465c0d47769b65ed266a49c815ffe4d865cc (patch)
treed5e47d69933da9b7cb7656e7b08e7070563e6915 /src
parent17e9ecac011832959b703b1d6a14788f9c8c829c (diff)
downloadpostgresql-cf0f465c0d47769b65ed266a49c815ffe4d865cc.tar.gz
postgresql-cf0f465c0d47769b65ed266a49c815ffe4d865cc.zip
Re-allow building on Microsoft Visual Studio 2013.
In commit 450ee7012 I supposed that all platforms we now care about have snprintf(), since that's required by C99. Turns out that Microsoft did not get around to adding that until VS2015. We've dropped support for VS2013 as of HEAD (cf 6203583b7), but not in the back branches, so add a hack for this in the back branches only. There's no easy shortcut to an exact emulation of standard snprintf in VS2013, but fortunately we don't need one: this code was just fine with using sprintf before 450ee7012, so we can make it do so again on that platform (and any others where the problem might crop up). Per bug #17681 from Daisuke Higuchi. Back-patch to v12, like the previous patch. Discussion: https://postgr.es/m/17681-485ba2ec13e7f392@postgresql.org
Diffstat (limited to 'src')
-rw-r--r--src/port/snprintf.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index b7eb2d7f27e..61b452844c3 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -110,6 +110,16 @@
#undef printf
/*
+ * We use the platform's native snprintf() for some machine-dependent cases.
+ * While that's required by C99, Microsoft Visual Studio lacks it before
+ * VS2015. Fortunately, we don't really need the length check in practice,
+ * so just fall back to native sprintf() on that platform.
+ */
+#if defined(_MSC_VER) && _MSC_VER < 1900 /* pre-VS2015 */
+#define snprintf(str,size,...) sprintf(str,__VA_ARGS__)
+#endif
+
+/*
* Info about where the formatted output is going.
*
* dopr and subroutines will not write at/past bufend, but snprintf