Commit 3df9e798 authored by Michael Hanselmann's avatar Michael Hanselmann Committed by Rémi Denis-Courmont

Add us_asprintf function

us_asprintf() has the same prototype as asprintf(), but doesn't use
the system locale.
Signed-off-by: default avatarMichael Hanselmann <public@hansmi.ch>
Signed-off-by: default avatarRémi Denis-Courmont <rdenis@simphalempin.com>
parent d50a6fad
...@@ -85,5 +85,6 @@ VLC_EXPORT( const char *, GetFallbackEncoding, ( void ) LIBVLC_USED ); ...@@ -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_strtod, ( const char *, char ** ) LIBVLC_USED );
VLC_EXPORT( double, us_atof, ( const char * ) LIBVLC_USED ); VLC_EXPORT( double, us_atof, ( const char * ) LIBVLC_USED );
VLC_EXPORT( int, us_asprintf, ( char **, const char *, ... ) LIBVLC_USED );
#endif #endif
...@@ -396,6 +396,7 @@ update_GetRelease ...@@ -396,6 +396,7 @@ update_GetRelease
update_NeedUpgrade update_NeedUpgrade
__update_New __update_New
update_WaitDownload update_WaitDownload
us_asprintf
us_atof us_atof
us_strtod us_strtod
utf8_fopen utf8_fopen
......
...@@ -100,3 +100,27 @@ double us_atof( const char *str ) ...@@ -100,3 +100,27 @@ double us_atof( const char *str )
return us_strtod( str, NULL ); 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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment