[Mplayer-cvslog] CVS: main cfgparser.c,1.57,1.58

Arpi of Ize arpi at mplayerhq.hu
Wed Oct 23 19:42:14 CEST 2002


Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv23984

Modified Files:
	cfgparser.c 
Log Message:
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 <olo at altkom.com.pl>


Index: cfgparser.c
===================================================================
RCS file: /cvsroot/mplayer/main/cfgparser.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- cfgparser.c	6 Oct 2002 05:54:12 -0000	1.57
+++ cfgparser.c	23 Oct 2002 17:42:11 -0000	1.58
@@ -16,6 +16,11 @@
 #include <string.h>
 #include <errno.h>
 #include <math.h>
+
+#ifdef USE_SETLOCALE
+#include <locale.h>
+#endif
+
 #include "config.h"
 
 #include "mp_msg.h"
@@ -550,25 +555,22 @@
 		case CONF_TYPE_FLOAT:
 			if (param == NULL)
 				goto err_missing_param;
-
+			/* <olo at altkom.com.pl> 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"




More information about the MPlayer-cvslog mailing list