summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDarkvater <Darkvater@openttd.org>2007-01-13 13:06:18 +0000
committerDarkvater <Darkvater@openttd.org>2007-01-13 13:06:18 +0000
commit1b6467b0e3e2958ec98f522c056c84d297519bf3 (patch)
tree4def23be809b8c4d91d3dc834c3fcda5d767a042 /src
parentd1449465c5d66cbde821d5a3826e278ca3a40edd (diff)
downloadopenttd-1b6467b0e3e2958ec98f522c056c84d297519bf3.tar.xz
(svn r8089) -[win32] MS-borkedness: All *nprintf functions are broken, but we didn't test to fix it ourselves when 'len = count'.
Diffstat (limited to 'src')
-rw-r--r--src/string.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/string.cpp b/src/string.cpp
index 4556ac64b..eeca3e809 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -160,11 +160,16 @@ int CDECL snprintf(char *str, size_t size, const char *format, ...)
}
#ifdef _MSC_VER
+/* *nprintf broken, not POSIX compliant, MSDN description
+ * - If len < count, then len characters are stored in buffer, a null-terminator is appended, and len is returned.
+ * - If len = count, then len characters are stored in buffer, no null-terminator is appended, and len is returned.
+ * - If len > count, then count characters are stored in buffer, no null-terminator is appended, and a negative value is returned
+ */
int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap)
{
int ret;
ret = _vsnprintf(str, size, format, ap);
- if (ret < 0) str[size - 1] = '\0';
+ if (ret < 0 || ret == 0) str[size - 1] = '\0';
return ret;
}
#endif /* _MSC_VER */