summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2012-04-26 03:32:18 +0000
committerCarsten Haitzler <raster@rasterman.com>2012-04-26 03:32:18 +0000
commit13c898bc7665453b080fe2a727804015f8c0c57c (patch)
tree98df1b9fd52bbc08d0dad0b4c56b35409773f241
parent31967880ca1f71d1b9d077e05095600859b0fcd3 (diff)
use profate atof that fixes up locale issues for string -> float
conversion. SVN revision: 70485
-rw-r--r--src/lib/elm_config.c34
-rw-r--r--src/lib/elm_map.c6
-rw-r--r--src/lib/elm_priv.h4
-rw-r--r--src/lib/elm_util.c17
-rw-r--r--src/lib/elm_win.c2
-rw-r--r--src/lib/els_tooltip.c2
6 files changed, 43 insertions, 22 deletions
diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c
index f4744a5fa..f8665ff7e 100644
--- a/src/lib/elm_config.c
+++ b/src/lib/elm_config.c
@@ -1354,23 +1354,23 @@ _env_get(void)
1354 if (s) _elm_config->thumbscroll_threshold = atoi(s); 1354 if (s) _elm_config->thumbscroll_threshold = atoi(s);
1355 // FIXME: floatformat locale issues here 1.0 vs 1,0 - should just be 1.0 1355 // FIXME: floatformat locale issues here 1.0 vs 1,0 - should just be 1.0
1356 s = getenv("ELM_THUMBSCROLL_MOMENTUM_THRESHOLD"); 1356 s = getenv("ELM_THUMBSCROLL_MOMENTUM_THRESHOLD");
1357 if (s) _elm_config->thumbscroll_momentum_threshold = atof(s); 1357 if (s) _elm_config->thumbscroll_momentum_threshold = _elm_atof(s);
1358 s = getenv("ELM_THUMBSCROLL_FRICTION"); 1358 s = getenv("ELM_THUMBSCROLL_FRICTION");
1359 if (s) _elm_config->thumbscroll_friction = atof(s); 1359 if (s) _elm_config->thumbscroll_friction = _elm_atof(s);
1360 s = getenv("ELM_THUMBSCROLL_BOUNCE_ENABLE"); 1360 s = getenv("ELM_THUMBSCROLL_BOUNCE_ENABLE");
1361 if (s) _elm_config->thumbscroll_bounce_enable = !!atoi(s); 1361 if (s) _elm_config->thumbscroll_bounce_enable = !!atoi(s);
1362 s = getenv("ELM_THUMBSCROLL_BOUNCE_FRICTION"); 1362 s = getenv("ELM_THUMBSCROLL_BOUNCE_FRICTION");
1363 if (s) _elm_config->thumbscroll_bounce_friction = atof(s); 1363 if (s) _elm_config->thumbscroll_bounce_friction = _elm_atof(s);
1364 s = getenv("ELM_PAGE_SCROLL_FRICTION"); 1364 s = getenv("ELM_PAGE_SCROLL_FRICTION");
1365 if (s) _elm_config->page_scroll_friction = atof(s); 1365 if (s) _elm_config->page_scroll_friction = _elm_atof(s);
1366 s = getenv("ELM_BRING_IN_SCROLL_FRICTION"); 1366 s = getenv("ELM_BRING_IN_SCROLL_FRICTION");
1367 if (s) _elm_config->bring_in_scroll_friction = atof(s); 1367 if (s) _elm_config->bring_in_scroll_friction = _elm_atof(s);
1368 s = getenv("ELM_ZOOM_FRICTION"); 1368 s = getenv("ELM_ZOOM_FRICTION");
1369 if (s) _elm_config->zoom_friction = atof(s); 1369 if (s) _elm_config->zoom_friction = _elm_atof(s);
1370 s = getenv("ELM_THUMBSCROLL_BORDER_FRICTION"); 1370 s = getenv("ELM_THUMBSCROLL_BORDER_FRICTION");
1371 if (s) 1371 if (s)
1372 { 1372 {
1373 friction = atof(s); 1373 friction = _elm_atof(s);
1374 if (friction < 0.0) 1374 if (friction < 0.0)
1375 friction = 0.0; 1375 friction = 0.0;
1376 1376
@@ -1382,7 +1382,7 @@ _env_get(void)
1382 s = getenv("ELM_THUMBSCROLL_SENSITIVITY_FRICTION"); 1382 s = getenv("ELM_THUMBSCROLL_SENSITIVITY_FRICTION");
1383 if (s) 1383 if (s)
1384 { 1384 {
1385 friction = atof(s); 1385 friction = _elm_atof(s);
1386 if (friction < 0.1) 1386 if (friction < 0.1)
1387 friction = 0.1; 1387 friction = 0.1;
1388 1388
@@ -1392,13 +1392,13 @@ _env_get(void)
1392 _elm_config->thumbscroll_sensitivity_friction = friction; 1392 _elm_config->thumbscroll_sensitivity_friction = friction;
1393 } 1393 }
1394 s = getenv("ELM_SCROLL_SMOOTH_AMOUNT"); 1394 s = getenv("ELM_SCROLL_SMOOTH_AMOUNT");
1395 if (s) _elm_config->scroll_smooth_amount = atof(s); 1395 if (s) _elm_config->scroll_smooth_amount = _elm_atof(s);
1396 s = getenv("ELM_SCROLL_SMOOTH_HISTORY_WEIGHT"); 1396 s = getenv("ELM_SCROLL_SMOOTH_HISTORY_WEIGHT");
1397 if (s) _elm_config->scroll_smooth_history_weight = atof(s); 1397 if (s) _elm_config->scroll_smooth_history_weight = _elm_atof(s);
1398 s = getenv("ELM_SCROLL_SMOOTH_FUTURE_TIME"); 1398 s = getenv("ELM_SCROLL_SMOOTH_FUTURE_TIME");
1399 if (s) _elm_config->scroll_smooth_future_time = atof(s); 1399 if (s) _elm_config->scroll_smooth_future_time = _elm_atof(s);
1400 s = getenv("ELM_SCROLL_SMOOTH_TIME_WINDOW"); 1400 s = getenv("ELM_SCROLL_SMOOTH_TIME_WINDOW");
1401 if (s) _elm_config->scroll_smooth_time_window = atof(s); 1401 if (s) _elm_config->scroll_smooth_time_window = _elm_atof(s);
1402 s = getenv("ELM_THEME"); 1402 s = getenv("ELM_THEME");
1403 if (s) eina_stringshare_replace(&_elm_config->theme, s); 1403 if (s) eina_stringshare_replace(&_elm_config->theme, s);
1404 1404
@@ -1457,7 +1457,7 @@ _env_get(void)
1457 if (s) _elm_config->font_cache = atoi(s); 1457 if (s) _elm_config->font_cache = atoi(s);
1458 1458
1459 s = getenv("ELM_SCALE"); 1459 s = getenv("ELM_SCALE");
1460 if (s) _elm_config->scale = atof(s); 1460 if (s) _elm_config->scale = _elm_atof(s);
1461 1461
1462 s = getenv("ELM_FINGER_SIZE"); 1462 s = getenv("ELM_FINGER_SIZE");
1463 if (s) _elm_config->finger_size = atoi(s); 1463 if (s) _elm_config->finger_size = atoi(s);
@@ -1468,13 +1468,13 @@ _env_get(void)
1468 s = getenv("ELM_PASSWORD_SHOW_LAST_TIMEOUT"); 1468 s = getenv("ELM_PASSWORD_SHOW_LAST_TIMEOUT");
1469 if (s) 1469 if (s)
1470 { 1470 {
1471 double pw_show_last_timeout = atof(s); 1471 double pw_show_last_timeout = _elm_atof(s);
1472 if (pw_show_last_timeout >= 0.0) 1472 if (pw_show_last_timeout >= 0.0)
1473 _elm_config->password_show_last_timeout = pw_show_last_timeout; 1473 _elm_config->password_show_last_timeout = pw_show_last_timeout;
1474 } 1474 }
1475 1475
1476 s = getenv("ELM_FPS"); 1476 s = getenv("ELM_FPS");
1477 if (s) _elm_config->fps = atof(s); 1477 if (s) _elm_config->fps = _elm_atof(s);
1478 if (_elm_config->fps < 1.0) _elm_config->fps = 1.0; 1478 if (_elm_config->fps < 1.0) _elm_config->fps = 1.0;
1479 1479
1480 s = getenv("ELM_MODULES"); 1480 s = getenv("ELM_MODULES");
@@ -1488,7 +1488,7 @@ _env_get(void)
1488 s = getenv("ELM_TOOLTIP_DELAY"); 1488 s = getenv("ELM_TOOLTIP_DELAY");
1489 if (s) 1489 if (s)
1490 { 1490 {
1491 double delay = atof(s); 1491 double delay = _elm_atof(s);
1492 if (delay >= 0.0) 1492 if (delay >= 0.0)
1493 _elm_config->tooltip_delay = delay; 1493 _elm_config->tooltip_delay = delay;
1494 } 1494 }
@@ -1515,7 +1515,7 @@ _env_get(void)
1515 if (s) _elm_config->icon_size = atoi(s); 1515 if (s) _elm_config->icon_size = atoi(s);
1516 1516
1517 s = getenv("ELM_LONGPRESS_TIMEOUT"); 1517 s = getenv("ELM_LONGPRESS_TIMEOUT");
1518 if (s) _elm_config->longpress_timeout = atof(s); 1518 if (s) _elm_config->longpress_timeout = _elm_atof(s);
1519 if (_elm_config->longpress_timeout < 0.0) 1519 if (_elm_config->longpress_timeout < 0.0)
1520 _elm_config->longpress_timeout = 0.0; 1520 _elm_config->longpress_timeout = 0.0;
1521 1521
diff --git a/src/lib/elm_map.c b/src/lib/elm_map.c
index bffd93000..46ad77118 100644
--- a/src/lib/elm_map.c
+++ b/src/lib/elm_map.c
@@ -2675,8 +2675,8 @@ cb_dump_name_attrs(void *data, const char *key, const char *value)
2675 Name_Dump *dump = (Name_Dump*)data; 2675 Name_Dump *dump = (Name_Dump*)data;
2676 if (!dump) return EINA_FALSE; 2676 if (!dump) return EINA_FALSE;
2677 2677
2678 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = atof(value); 2678 if (!strncmp(key, NOMINATIM_ATTR_LON, sizeof(NOMINATIM_ATTR_LON))) dump->lon = _elm_atof(value);
2679 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = atof(value); 2679 else if (!strncmp(key, NOMINATIM_ATTR_LAT, sizeof(NOMINATIM_ATTR_LAT))) dump->lat = _elm_atof(value);
2680 2680
2681 return EINA_TRUE; 2681 return EINA_TRUE;
2682} 2682}
@@ -2709,7 +2709,7 @@ cb_route_dump(void *data, Eina_Simple_XML_Type type, const char *value, unsigned
2709 char *buf = malloc(length); 2709 char *buf = malloc(length);
2710 if (!buf) return EINA_FALSE; 2710 if (!buf) return EINA_FALSE;
2711 snprintf(buf, length, "%s", value); 2711 snprintf(buf, length, "%s", value);
2712 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = atof(buf); 2712 if (dump->id == ROUTE_XML_DISTANCE) dump->distance = _elm_atof(buf);
2713 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf); 2713 else if (!(dump->description) && (dump->id == ROUTE_XML_DESCRIPTION)) dump->description = strdup(buf);
2714 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf); 2714 else if (dump->id == ROUTE_XML_COORDINATES) dump->coordinates = strdup(buf);
2715 free(buf); 2715 free(buf);
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
index f931bc074..c03430673 100644
--- a/src/lib/elm_priv.h
+++ b/src/lib/elm_priv.h
@@ -15,6 +15,8 @@
15 15
16#include "elm_widget.h" 16#include "elm_widget.h"
17 17
18#include <langinfo.h>
19
18#define CRITICAL(...) EINA_LOG_DOM_CRIT(_elm_log_dom, __VA_ARGS__) 20#define CRITICAL(...) EINA_LOG_DOM_CRIT(_elm_log_dom, __VA_ARGS__)
19#define ERR(...) EINA_LOG_DOM_ERR (_elm_log_dom, __VA_ARGS__) 21#define ERR(...) EINA_LOG_DOM_ERR (_elm_log_dom, __VA_ARGS__)
20#define WRN(...) EINA_LOG_DOM_WARN(_elm_log_dom, __VA_ARGS__) 22#define WRN(...) EINA_LOG_DOM_WARN(_elm_log_dom, __VA_ARGS__)
@@ -312,4 +314,6 @@ _elm_dgettext(const char *string)
312/* Used by the paste handler */ 314/* Used by the paste handler */
313void _elm_entry_entry_paste(Evas_Object *obj, const char *entry); 315void _elm_entry_entry_paste(Evas_Object *obj, const char *entry);
314 316
317double _elm_atof(const char *s);
318
315#endif 319#endif
diff --git a/src/lib/elm_util.c b/src/lib/elm_util.c
index 935acd3d4..7e3686051 100644
--- a/src/lib/elm_util.c
+++ b/src/lib/elm_util.c
@@ -44,3 +44,20 @@ _elm_util_text_to_mkup(const char *text)
44{ 44{
45 return evas_textblock_text_utf8_to_markup(NULL, text); 45 return evas_textblock_text_utf8_to_markup(NULL, text);
46} 46}
47
48double
49_elm_atof(const char *s)
50{
51 char *cradix, *buf, *p;
52
53 if ((!s) || (!s[0])) return 0.0;
54 cradix = nl_langinfo(RADIXCHAR);
55 if (!cradix) return atof(s);
56 buf = alloca(strlen(s) + 1);
57 strcpy(buf, s);
58 for (p = buf; *p; p++)
59 {
60 if (*p == '.') *p = *cradix;
61 }
62 return atof(buf);
63}
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
index 1a52ce04f..400d6691e 100644
--- a/src/lib/elm_win.c
+++ b/src/lib/elm_win.c
@@ -172,7 +172,7 @@ _shot_delay_get(Elm_Win *win)
172 *pd = *p; 172 *pd = *p;
173 } 173 }
174 *pd = 0; 174 *pd = 0;
175 v = atof(d); 175 v = _elm_atof(d);
176 free(d); 176 free(d);
177 return v; 177 return v;
178 } 178 }
diff --git a/src/lib/els_tooltip.c b/src/lib/els_tooltip.c
index f1a451f8f..a7da1f69c 100644
--- a/src/lib/els_tooltip.c
+++ b/src/lib/els_tooltip.c
@@ -324,7 +324,7 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt)
324 str = edje_object_data_get(tt->tooltip, "hide_timeout"); 324 str = edje_object_data_get(tt->tooltip, "hide_timeout");
325 if (str) 325 if (str)
326 { 326 {
327 tt->hide_timeout = atof(str); 327 tt->hide_timeout = _elm_atof(str);
328 if (tt->hide_timeout < 0.0) tt->hide_timeout = 0.0; 328 if (tt->hide_timeout < 0.0) tt->hide_timeout = 0.0;
329 } 329 }
330 330