From 4aeac332f6ed5c0be1a1664903bf7794c1226b1c Mon Sep 17 00:00:00 2001 From: arpi Date: Wed, 23 Oct 2002 17:42:12 +0000 Subject: 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 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7871 b3059339-0415-0410-9bf9-f77b7e298cf2 --- cfgparser.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'cfgparser.c') diff --git a/cfgparser.c b/cfgparser.c index e3c783e16e..9ea2d0ac22 100644 --- a/cfgparser.c +++ b/cfgparser.c @@ -16,6 +16,11 @@ #include #include #include + +#ifdef USE_SETLOCALE +#include +#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; - + /* 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" -- cgit v1.2.3