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

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