Commit 71587594 authored by Cyril Mathé's avatar Cyril Mathé Committed by Rémi Denis-Courmont

Add a us_strtof function to prevent some problem

Signed-off-by: Rémi Denis-Courmont's avatarRémi Denis-Courmont <remi@remlab.net>
parent d385b8dc
......@@ -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 );
......
......@@ -385,6 +385,7 @@ update_WaitDownload
us_asprintf
us_atof
us_strtod
us_strtof
utf8_fopen
utf8_fprintf
utf8_loaddir
......
......@@ -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.
......
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