]> git.sesse.net Git - vlc/commitdiff
Add a us_strtof function to prevent some problem
authorCyril Mathé <cmathe@actech-innovation.com>
Tue, 14 Apr 2009 09:48:33 +0000 (11:48 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Fri, 17 Apr 2009 17:42:29 +0000 (20:42 +0300)
Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
include/vlc_charset.h
src/libvlccore.sym
src/text/charset.c

index ddd50df83d68828c7410815ea930f5eaadb8bb1f..cae46c778633c8be451163c1792a0f2a48dfd0ac 100644 (file)
@@ -111,6 +111,7 @@ static inline char *FromLatin1 (const char *latin)
 VLC_EXPORT( const char *, GetFallbackEncoding, ( void ) LIBVLC_USED );
 
 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_asprintf, ( char **, const char *, ... ) LIBVLC_USED );
 
index af5a6b19e38b87c96edb7247927843c4d24b0783..77a494c4d62e15f398f0116c641a9d2e8e3de5a0 100644 (file)
@@ -385,6 +385,7 @@ update_WaitDownload
 us_asprintf
 us_atof
 us_strtod
+us_strtof
 utf8_fopen
 utf8_fprintf
 utf8_loaddir
index 6d4d2a7b4030f64b3d1c249cde0c29144c99babc..7812cb917edf046c0f8e15e6bdbd659ed7d189f7 100644 (file)
@@ -91,6 +91,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.