Mercurial > mplayer.hg
changeset 7611:411886c03c54
strtod is locale-dependant, so it may only accept either '.' or ',' as decimal point,
we do now make sure both works by providing a fallback.
If anyone knows a better/simpler algorithmn than I used, feel free to improve.
author | atmos4 |
---|---|
date | Sun, 06 Oct 2002 05:54:12 +0000 |
parents | 876495f714dc |
children | bf7f2bd2eb24 |
files | cfgparser.c |
diffstat | 1 files changed, 16 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/cfgparser.c Sun Oct 06 02:59:04 2002 +0000 +++ b/cfgparser.c Sun Oct 06 05:54:12 2002 +0000 @@ -15,6 +15,7 @@ #include <fcntl.h> #include <string.h> #include <errno.h> +#include <math.h> #include "config.h" #include "mp_msg.h" @@ -552,8 +553,22 @@ tmp_float = strtod(param, &endptr); - if ((*endptr == ':') || (*endptr == '/')) + switch(*endptr) { + case ':': + case '/': tmp_float /= strtod(endptr+1, &endptr); + break; + case '.': + case ',': + /* we also handle floats specified with + * non-locale decimal point ::atmos + */ + if(tmp_float<0) + tmp_float -= 1.0/pow(10,strlen(endptr+1)) * strtod(endptr+1, &endptr); + else + tmp_float += 1.0/pow(10,strlen(endptr+1)) * strtod(endptr+1, &endptr); + break; + } if (*endptr) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be a floating point number"