Commit 0b00646d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

us_strtod: do not make any kludgy assumptions about number formats

parent a2c338bb
...@@ -378,24 +378,21 @@ char *vlc_fix_readdir( const char *psz_string ) ...@@ -378,24 +378,21 @@ char *vlc_fix_readdir( const char *psz_string )
/** /**
* us_strtod() has the same prototype as ANSI C strtod() but it expects * us_strtod() has the same prototype as ANSI C strtod() but it uses the
* a dot as decimal separator regardless of the system locale. * POSIX/C decimal format, regardless of the current numeric locale.
*/ */
double us_strtod( const char *str, char **end ) double us_strtod( const char *str, char **end )
{ {
char dup[strlen( str ) + 1], *ptr; locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
double d; locale_t oldloc = uselocale (loc);
strcpy( dup, str ); double res = strtod (str, end);
ptr = strchr( dup, ',' ); if (loc != (locale_t)0)
if( ptr != NULL ) {
*ptr = '\0'; uselocale (oldloc);
freelocale (loc);
d = strtod( dup, &ptr ); }
if( end != NULL ) return res;
*end = (char *)&str[ptr - dup];
return d;
} }
/** /**
......
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