]> git.sesse.net Git - vlc/blobdiff - src/text/charset.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / src / text / charset.c
index eaed11be71e2ed85178c36736d4c79b9216a25ec..07b814ee09a9a372195fb1f915fff25471d20d9a 100644 (file)
@@ -36,7 +36,6 @@
 #endif
 
 #ifdef __APPLE__
-#   include <errno.h>
 #   include <string.h>
 #   include <xlocale.h>
 #endif
@@ -91,6 +90,26 @@ double us_strtod( const char *str, char **end )
     return res;
 }
 
+
+/**
+ * us_strtof() has the same prototype as ANSI C strtof() but it uses the
+ * POSIX/C decimal format, regardless of the current numeric locale.
+ */
+float us_strtof( const char *str, char **end )
+{
+    locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
+    locale_t oldloc = uselocale (loc);
+    float res = strtof (str, end);
+
+    if (loc != (locale_t)0)
+    {
+        uselocale (oldloc);
+        freelocale (loc);
+    }
+    return res;
+}
+
+
 /**
  * us_atof() has the same prototype as ANSI C atof() but it expects a dot
  * as decimal separator, regardless of the system locale.
@@ -100,3 +119,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;
+}