This patch implements snprintf_l function in a way similar to the other
functions in src/support/win32/locale_win32.cpp and locale_win32.h,
calling upon vsnprintf for which there is a MingW correct alternative.
Note! __USE_MINGW_ANSI_STDIO is not modified in this patch. In order to
use the __mingw version it must be defined before including the MingW
headers.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@195044 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/support/win32/locale_win32.h b/include/support/win32/locale_win32.h
index e768af5..f728d23 100644
--- a/include/support/win32/locale_win32.h
+++ b/include/support/win32/locale_win32.h
@@ -103,9 +103,9 @@
#define sscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
#define vsscanf_l( __s, __l, __f, ...) _sscanf_l( __s, __f, __l, __VA_ARGS__ )
#define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ )
-#define snprintf_l( __s, __n, __l, __f, ... ) _snprintf_l( __s, __n, __f, __l, __VA_ARGS__ )
#define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, __VA_ARGS__ )
#define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, __VA_ARGS__ )
+int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...);
int asprintf_l( char **ret, locale_t loc, const char *format, ... );
int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap );
diff --git a/src/support/win32/locale_win32.cpp b/src/support/win32/locale_win32.cpp
index 1729d84..5a43743 100644
--- a/src/support/win32/locale_win32.cpp
+++ b/src/support/win32/locale_win32.cpp
@@ -80,6 +80,16 @@
return wctob( c );
}
+int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...)
+{
+ __locale_raii __current( uselocale(loc), uselocale );
+ va_list ap;
+ va_start( ap, format );
+ int result = vsnprintf( ret, n, format, ap );
+ va_end(ap);
+ return result;
+}
+
int asprintf_l( char **ret, locale_t loc, const char *format, ... )
{
va_list ap;