mirror of
https://github.com/mpv-player/mpv
synced 2025-01-11 17:39:38 +00:00
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. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7612 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
ff72be050b
commit
496963471f
17
cfgparser.c
17
cfgparser.c
@ -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 @@ static int config_read_option(m_config_t *config,config_t** conf_list, char *opt
|
||||
|
||||
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"
|
||||
|
Loading…
Reference in New Issue
Block a user