Changeset 71f0e10dee124f93351697f8c1fec7236b724e02
- Timestamp:
- 05/21/08 20:59:16
(3 months ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1211396356 +0300
- git-parent:
[bb1fb263758ffb26e0d2887bb309d274972687c2]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1211396343 +0300
- Message:
Remove unused i18n_atof
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r6bc9799 |
r71f0e10 |
|
| 82 | 82 | VLC_EXPORT( const char *, GetFallbackEncoding, ( void ) ); |
|---|
| 83 | 83 | |
|---|
| 84 | | VLC_INTERNAL( double, i18n_atof, ( const char * ) ); |
|---|
| 85 | 84 | VLC_EXPORT( double, us_strtod, ( const char *, char ** ) ); |
|---|
| 86 | 85 | VLC_EXPORT( double, us_atof, ( const char * ) ); |
|---|
| r6bc9799 |
r71f0e10 |
|
| 1 | 1 | /***************************************************************************** |
|---|
| 2 | | * i18n_atof.c: Test for i18n_atof |
|---|
| | 2 | * i18n_atof.c: Test for us_atof |
|---|
| 3 | 3 | ***************************************************************************** |
|---|
| 4 | 4 | * Copyright (C) 2006 Rémi Denis-Courmont |
|---|
| … | … | |
| 37 | 37 | char *end; |
|---|
| 38 | 38 | |
|---|
| 39 | | assert (i18n_atof("0") == 0.); |
|---|
| 40 | | assert (i18n_atof("1") == 1.); |
|---|
| 41 | | assert (i18n_atof("1.") == 1.); |
|---|
| 42 | | assert (i18n_atof("1,") == 1.); |
|---|
| 43 | | assert (i18n_atof("1#") == 1.); |
|---|
| 44 | | assert (i18n_atof(dot9) == 999999.999999); |
|---|
| 45 | | assert (i18n_atof(comma9) == 999999.999999); |
|---|
| 46 | | assert (i18n_atof(sharp9) == 999999.); |
|---|
| 47 | | assert (i18n_atof("invalid") == 0.); |
|---|
| 48 | | |
|---|
| 49 | 39 | assert (us_atof("0") == 0.); |
|---|
| 50 | 40 | assert (us_atof("1") == 1.); |
|---|
| r6bc9799 |
r71f0e10 |
|
| 378 | 378 | |
|---|
| 379 | 379 | |
|---|
| 380 | | static double i18n_strtod( const char *str, char **end ) |
|---|
| 381 | | { |
|---|
| 382 | | char *end_buf, e; |
|---|
| 383 | | double d; |
|---|
| 384 | | |
|---|
| 385 | | if( end == NULL ) |
|---|
| 386 | | end = &end_buf; |
|---|
| 387 | | d = strtod( str, end ); |
|---|
| 388 | | |
|---|
| 389 | | e = **end; |
|---|
| 390 | | if(( e == ',' ) || ( e == '.' )) |
|---|
| 391 | | { |
|---|
| 392 | | char dup[strlen( str ) + 1]; |
|---|
| 393 | | strcpy( dup, str ); |
|---|
| 394 | | |
|---|
| 395 | | if( dup == NULL ) |
|---|
| 396 | | return d; |
|---|
| 397 | | |
|---|
| 398 | | dup[*end - str] = ( e == ',' ) ? '.' : ','; |
|---|
| 399 | | d = strtod( dup, end ); |
|---|
| 400 | | } |
|---|
| 401 | | return d; |
|---|
| 402 | | } |
|---|
| 403 | | |
|---|
| 404 | | /** |
|---|
| 405 | | * i18n_atof() has the same prototype as ANSI C atof() but it accepts |
|---|
| 406 | | * either decimal separator when deserializing the string to a float number, |
|---|
| 407 | | * independant of the local computer setting. |
|---|
| 408 | | */ |
|---|
| 409 | | double i18n_atof( const char *str ) |
|---|
| 410 | | { |
|---|
| 411 | | return i18n_strtod( str, NULL ); |
|---|
| 412 | | } |
|---|
| 413 | | |
|---|
| 414 | | |
|---|
| 415 | 380 | /** |
|---|
| 416 | 381 | * us_strtod() has the same prototype as ANSI C strtod() but it expects |
|---|