[Mplayer-cvslog] CVS: main cfgparser.c,1.56,1.57
Atmosfear
atmos4 at mplayerhq.hu
Sun Oct 6 07:54:26 CEST 2002
Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv4308
Modified Files:
cfgparser.c
Log Message:
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.
Index: cfgparser.c
===================================================================
RCS file: /cvsroot/mplayer/main/cfgparser.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- cfgparser.c 26 Sep 2002 00:28:32 -0000 1.56
+++ cfgparser.c 6 Oct 2002 05:54:12 -0000 1.57
@@ -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 @@
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"
More information about the MPlayer-cvslog
mailing list