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
This commit is contained in:
Yaron Keren 2013-11-18 21:12:14 +00:00
parent ff924b08dd
commit fbeb63c0d1
2 changed files with 11 additions and 1 deletions

View File

@ -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 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 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 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 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__ ) #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 asprintf_l( char **ret, locale_t loc, const char *format, ... );
int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap ); int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap );

View File

@ -80,6 +80,16 @@ int wctob_l( wint_t c, locale_t loc )
return wctob( c ); 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, ... ) int asprintf_l( char **ret, locale_t loc, const char *format, ... )
{ {
va_list ap; va_list ap;