1
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:
Michael Hanselmann 2008-12-02 01:06:00 +01:00 committed by Rémi Denis-Courmont
parent d50a6fad1f
commit 3df9e79877
3 changed files with 26 additions and 0 deletions

View File

@ -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

View File

@ -396,6 +396,7 @@ update_GetRelease
update_NeedUpgrade
__update_New
update_WaitDownload
us_asprintf
us_atof
us_strtod
utf8_fopen

View File

@ -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;
}