From fbeb63c0d15874bd71b6e2201f69a06e1336335e Mon Sep 17 00:00:00 2001 From: Yaron Keren Date: Mon, 18 Nov 2013 21:12:14 +0000 Subject: [PATCH] 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. llvm-svn: 195044 --- libcxx/include/support/win32/locale_win32.h | 2 +- libcxx/src/support/win32/locale_win32.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libcxx/include/support/win32/locale_win32.h b/libcxx/include/support/win32/locale_win32.h index e768af50c14c..f728d234472f 100644 --- a/libcxx/include/support/win32/locale_win32.h +++ b/libcxx/include/support/win32/locale_win32.h @@ -103,9 +103,9 @@ isupper_l(int c, _locale_t loc) #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/libcxx/src/support/win32/locale_win32.cpp b/libcxx/src/support/win32/locale_win32.cpp index 1729d84a366a..5a43743470d5 100644 --- a/libcxx/src/support/win32/locale_win32.cpp +++ b/libcxx/src/support/win32/locale_win32.cpp @@ -80,6 +80,16 @@ int wctob_l( wint_t c, locale_t loc ) 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;