mirror of
https://code.videolan.org/videolan/vlc
synced 2024-07-21 07:24:15 +02:00
Add us_asprintf function
us_asprintf() has the same prototype as asprintf(), but doesn't use the system locale. Signed-off-by: Michael Hanselmann <public@hansmi.ch> Signed-off-by: Rémi Denis-Courmont <rdenis@simphalempin.com>
This commit is contained in:
parent
d50a6fad1f
commit
3df9e79877
@ -85,5 +85,6 @@ VLC_EXPORT( const char *, GetFallbackEncoding, ( void ) LIBVLC_USED );
|
||||
|
||||
VLC_EXPORT( double, us_strtod, ( const char *, char ** ) LIBVLC_USED );
|
||||
VLC_EXPORT( double, us_atof, ( const char * ) LIBVLC_USED );
|
||||
VLC_EXPORT( int, us_asprintf, ( char **, const char *, ... ) LIBVLC_USED );
|
||||
|
||||
#endif
|
||||
|
@ -396,6 +396,7 @@ update_GetRelease
|
||||
update_NeedUpgrade
|
||||
__update_New
|
||||
update_WaitDownload
|
||||
us_asprintf
|
||||
us_atof
|
||||
us_strtod
|
||||
utf8_fopen
|
||||
|
@ -100,3 +100,27 @@ double us_atof( const char *str )
|
||||
return us_strtod( str, NULL );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* us_asprintf() has the same prototype as asprintf(), but doesn't use
|
||||
* the system locale.
|
||||
*/
|
||||
int us_asprintf( char **ret, const char *format, ... )
|
||||
{
|
||||
va_list ap;
|
||||
locale_t loc = newlocale( LC_NUMERIC_MASK, "C", NULL );
|
||||
locale_t oldloc = uselocale( loc );
|
||||
int i_rc;
|
||||
|
||||
va_start( ap, format );
|
||||
i_rc = vasprintf( ret, format, ap );
|
||||
va_end( ap );
|
||||
|
||||
if ( loc != (locale_t)0 )
|
||||
{
|
||||
uselocale( oldloc );
|
||||
freelocale( loc );
|
||||
}
|
||||
|
||||
return i_rc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user