# HG changeset patch # User arpi # Date 1035394932 0 # Node ID b571ae470520fc9cdb4f1e2fe75bf42227acc11d # Parent 0f31eefed30f600c4a3dc338c4cbb9097bd66dae 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 diff -r 0f31eefed30f -r b571ae470520 cfgparser.c --- a/cfgparser.c Wed Oct 23 17:25:34 2002 +0000 +++ b/cfgparser.c Wed Oct 23 17:42:12 2002 +0000 @@ -16,6 +16,11 @@ #include #include #include + +#ifdef USE_SETLOCALE +#include +#endif + #include "config.h" #include "mp_msg.h" @@ -550,25 +555,22 @@ 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" diff -r 0f31eefed30f -r b571ae470520 input/input.c --- a/input/input.c Wed Oct 23 17:25:34 2002 +0000 +++ b/input/input.c Wed Oct 23 17:42:12 2002 +0000 @@ -12,6 +12,10 @@ #include #include +#ifdef USE_SETLOCALE +#include +#endif + #include "input.h" #include "mouse.h" #ifdef MP_DEBUG @@ -470,7 +474,14 @@ break; case MP_CMD_ARG_FLOAT: errno = 0; + /* Use portable C locale for parsing floats: */ +#ifdef USE_SETLOCALE + setlocale(LC_NUMERIC, "C"); +#endif cmd->args[i].v.f = atof(ptr); +#ifdef USE_SETLOCALE + setlocale(LC_NUMERIC, ""); +#endif if(errno != 0) { mp_msg(MSGT_INPUT,MSGL_ERR,"Command %s : argument %d isn't a float\n",cmd_def->name,i+1); ptr = NULL;