summaryrefslogtreecommitdiffstats
path: root/cfgparser.c
diff options
context:
space:
mode:
authoratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-06 05:54:12 +0000
committeratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-06 05:54:12 +0000
commit496963471f7be2e34631f0aeae49b2a960d94a97 (patch)
tree1bb7dcb87dc9edc030f8df111b1f33eee72d6070 /cfgparser.c
parentff72be050bbe0e494f5885ec723c5e6857431ef7 (diff)
downloadmpv-496963471f7be2e34631f0aeae49b2a960d94a97.tar.bz2
mpv-496963471f7be2e34631f0aeae49b2a960d94a97.tar.xz
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
Diffstat (limited to 'cfgparser.c')
-rw-r--r--cfgparser.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/cfgparser.c b/cfgparser.c
index 89b54e6aa8..e3c783e16e 100644
--- a/cfgparser.c
+++ b/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"