[vlc-commits] commit: Add us_vasprintf() function (Pierre Ynard )
git at videolan.org
git at videolan.org
Wed Jan 12 19:37:10 CET 2011
vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Wed Jan 12 19:33:19 2011 +0100| [5d3ffa0e963370f821e71dfb055b49ed7d8c8a2d] | committer: Pierre Ynard
Add us_vasprintf() function
For use within already variadic functions
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5d3ffa0e963370f821e71dfb055b49ed7d8c8a2d
---
include/vlc_charset.h | 1 +
src/libvlccore.sym | 1 +
src/text/charset.c | 27 ++++++++++++++++++++-------
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/include/vlc_charset.h b/include/vlc_charset.h
index 07f9dee..5c7590f 100644
--- a/include/vlc_charset.h
+++ b/include/vlc_charset.h
@@ -114,6 +114,7 @@ VLC_EXPORT( void *, ToCharset, ( const char *charset, const char *in, size_t *ou
VLC_EXPORT( double, us_strtod, ( const char *, char ** ) LIBVLC_USED );
VLC_EXPORT( float, us_strtof, ( const char *, char ** ) LIBVLC_USED );
VLC_EXPORT( double, us_atof, ( const char * ) LIBVLC_USED );
+VLC_EXPORT( int, us_vasprintf, ( char **, const char *, va_list ) );
VLC_EXPORT( int, us_asprintf, ( char **, const char *, ... ) LIBVLC_USED );
#endif
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index c35e1c3..23c41bc 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -453,6 +453,7 @@ us_asprintf
us_atof
us_strtod
us_strtof
+us_vasprintf
vlc_fopen
utf8_fprintf
vlc_loaddir
diff --git a/src/text/charset.c b/src/text/charset.c
index 1722210..edb5dae 100644
--- a/src/text/charset.c
+++ b/src/text/charset.c
@@ -92,19 +92,15 @@ double us_atof( const char *str )
/**
- * us_asprintf() has the same prototype as asprintf(), but doesn't use
+ * us_vasprintf() has the same prototype as vasprintf(), but doesn't use
* the system locale.
*/
-int us_asprintf( char **ret, const char *format, ... )
+int us_vasprintf( char **ret, const char *format, va_list ap )
{
- 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 );
+ int i_rc = vasprintf( ret, format, ap );
if ( loc != (locale_t)0 )
{
@@ -114,3 +110,20 @@ int us_asprintf( char **ret, const char *format, ... )
return i_rc;
}
+
+
+/**
+ * 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;
+ int i_rc;
+
+ va_start( ap, format );
+ i_rc = us_vasprintf( ret, format, ap );
+ va_end( ap );
+
+ return i_rc;
+}
More information about the vlc-commits
mailing list