diff options
author | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-10-23 17:42:12 +0000 |
---|---|---|
committer | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-10-23 17:42:12 +0000 |
commit | 4aeac332f6ed5c0be1a1664903bf7794c1226b1c (patch) | |
tree | eb61ed6fe05a2f370330867fee7d288e43036ab5 /cfgparser.c | |
parent | 57f9f8fa14ba1c8b731a627153ab565fcfa816d5 (diff) | |
download | mpv-4aeac332f6ed5c0be1a1664903bf7794c1226b1c.tar.bz2 mpv-4aeac332f6ed5c0be1a1664903bf7794c1226b1c.tar.xz |
Fixed a bug in MPlayer which would prevent proper parsing of
some floating point options when the locale used has a decimal point
other than the dot character (".").
My patch inserts calls to setlocale around float parsing functions strtod()
and atof() in cfgparser.c and input/input.c.
patch by Aleksander Adamowski <olo@altkom.com.pl>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7871 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'cfgparser.c')
-rw-r--r-- | cfgparser.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/cfgparser.c b/cfgparser.c index e3c783e16e..9ea2d0ac22 100644 --- a/cfgparser.c +++ b/cfgparser.c @@ -16,6 +16,11 @@ #include <string.h> #include <errno.h> #include <math.h> + +#ifdef USE_SETLOCALE +#include <locale.h> +#endif + #include "config.h" #include "mp_msg.h" @@ -550,25 +555,22 @@ static int config_read_option(m_config_t *config,config_t** conf_list, char *opt case CONF_TYPE_FLOAT: if (param == NULL) goto err_missing_param; - + /* <olo@altkom.com.pl> Use portable C locale for parsing floats: */ +#ifdef USE_SETLOCALE + setlocale(LC_NUMERIC, "C"); +#endif tmp_float = strtod(param, &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); + default: break; } +#ifdef USE_SETLOCALE + setlocale(LC_NUMERIC, ""); +#endif if (*endptr) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be a floating point number" |