Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
From f29beb1884251af05be10f35c70364d2d8d891be Mon Sep 17 00:00:00 2001
From: naszar <naszar@ya.ru>
Date: Sun, 6 Jul 2014 22:58:19 +1100
Subject: [PATCH] Fix bug with locales, when *localeconv()->decimal_point = ','
Signed-off-by: naszar <naszar@ya.ru>
---
src/options.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/options.c b/src/options.c
index d81d8fb..84929e1 100644
--- a/src/options.c
+++ b/src/options.c
@@ -5,6 +5,7 @@
#include "gamma_vals.h"
#include <sys/types.h>
#include <sys/stat.h>
+#include <locale.h>
#define SIZEOF(X) (sizeof(X)/sizeof(X[0]))
/**\brief Redshift options.*/
@@ -330,10 +331,14 @@ int opt_parse_map(char *map){
return RET_FUN_FAILED;
}
currstr=map;
+
+/* Set LC_NUMERIC from C to user ENV, it will be done later by gtk, but it must be done now
+ to correct string to float conversion */
+ setlocale(LC_NUMERIC,"");
+
for( i=0; i<cnt; ++i ){
- currsep=strchr(currstr,',');
currend=strchr(currstr,';');
- curr_map[i].elev=atof(currstr);
+ curr_map[i].elev=strtof(currstr, &currsep);
curr_map[i].temp=atof(++currsep);
if( curr_map[i].elev > prevelev ){
free(curr_map);
--
2.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.