VLC_EXPORT( const char *, GetFallbackEncoding, ( void ) );
-VLC_INTERNAL( double, i18n_atof, ( const char * ) );
VLC_EXPORT( double, us_strtod, ( const char *, char ** ) );
VLC_EXPORT( double, us_atof, ( const char * ) );
/*****************************************************************************
- * i18n_atof.c: Test for i18n_atof
+ * i18n_atof.c: Test for us_atof
*****************************************************************************
* Copyright (C) 2006 Rémi Denis-Courmont
* $Id$
const char sharp9[] = "999999#999999";
char *end;
- assert (i18n_atof("0") == 0.);
- assert (i18n_atof("1") == 1.);
- assert (i18n_atof("1.") == 1.);
- assert (i18n_atof("1,") == 1.);
- assert (i18n_atof("1#") == 1.);
- assert (i18n_atof(dot9) == 999999.999999);
- assert (i18n_atof(comma9) == 999999.999999);
- assert (i18n_atof(sharp9) == 999999.);
- assert (i18n_atof("invalid") == 0.);
-
assert (us_atof("0") == 0.);
assert (us_atof("1") == 1.);
assert (us_atof("1.") == 1.);
}
-static double i18n_strtod( const char *str, char **end )
-{
- char *end_buf, e;
- double d;
-
- if( end == NULL )
- end = &end_buf;
- d = strtod( str, end );
-
- e = **end;
- if(( e == ',' ) || ( e == '.' ))
- {
- char dup[strlen( str ) + 1];
- strcpy( dup, str );
-
- if( dup == NULL )
- return d;
-
- dup[*end - str] = ( e == ',' ) ? '.' : ',';
- d = strtod( dup, end );
- }
- return d;
-}
-
-/**
- * i18n_atof() has the same prototype as ANSI C atof() but it accepts
- * either decimal separator when deserializing the string to a float number,
- * independant of the local computer setting.
- */
-double i18n_atof( const char *str )
-{
- return i18n_strtod( str, NULL );
-}
-
-
/**
* us_strtod() has the same prototype as ANSI C strtod() but it expects
* a dot as decimal separator regardless of the system locale.