Functions __ms_snprintf() and __ms_vsnprintf() contains same logic and code
around _vscprintf() and _vsnprintf() wrappers. Remove duplicated code from
__ms_snprintf() and redirects __ms_snprintf() to __ms_vsnprintf().
---
mingw-w64-crt/stdio/snprintf.c | 22 +---------------------
1 file changed, 1 insertion(+), 21 deletions(-)
diff --git a/mingw-w64-crt/stdio/snprintf.c b/mingw-w64-crt/stdio/snprintf.c
index 0bb5556fe3de..2e43a67aeee4 100644
--- a/mingw-w64-crt/stdio/snprintf.c
+++ b/mingw-w64-crt/stdio/snprintf.c
@@ -12,27 +12,7 @@ int __cdecl __ms_snprintf(char* buffer, size_t n, const char
*format, ...)
va_list argptr;
va_start(argptr, format);
-
- /* _vsnprintf() does not work with zero length buffer
- * so count number of character by _vscprintf() call */
- if (n == 0 || !buffer)
- {
- retval = _vscprintf(format, argptr);
- va_end(argptr);
- return retval;
- }
-
- retval = _vsnprintf (buffer, n, format, argptr);
-
- /* _vsnprintf() returns negative number if buffer is too small
- * so count number of character by _vscprintf() call */
- if (retval < 0)
- retval = _vscprintf(format, argptr);
-
- /* _vsnprintf() does not fill trailing null byte if there is not place for
it */
- if ((size_t)retval >= n)
- buffer[n-1] = '\0';
-
+ retval = __ms_vsnprintf(buffer, n, format, argptr);
va_end(argptr);
return retval;
}
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public