summaryrefslogtreecommitdiff
path: root/src/metadata.cpp
diff options
context:
space:
mode:
authorErkin Bahceci <erkinbah@gmail.com>2008-09-18 09:38:19 -0500
committerErkin Bahceci <erkinbah@gmail.com>2008-09-18 09:38:19 -0500
commitf4c5899495310bb4f4552086b55b340706802f11 (patch)
treee6a75d58ee4700f923478e4aec895d2795eb8863 /src/metadata.cpp
parente1ab59893e441e2d885f5b05fe8941d986311803 (diff)
downloadzcomp-f4c5899495310bb4f4552086b55b340706802f11.tar.gz
zcomp-f4c5899495310bb4f4552086b55b340706802f11.tar.bz2
Fix reading of floats in metadata for some locales.
Diffstat (limited to 'src/metadata.cpp')
-rw-r--r--src/metadata.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/metadata.cpp b/src/metadata.cpp
index 291b808..0a1528f 100644
--- a/src/metadata.cpp
+++ b/src/metadata.cpp
@@ -29,6 +29,7 @@
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
+#include <locale.h>
#include <boost/foreach.hpp>
#define foreach BOOST_FOREACH
@@ -257,12 +258,15 @@ initFloatValue (CompOption::Value &v,
xmlNodePtr node)
{
xmlChar *value;
+ char *loc;
v.set ((r.fMin () + r.fMax ()) / 2);
if (!doc)
return;
+ loc = setlocale (LC_NUMERIC, NULL);
+ setlocale (LC_NUMERIC, "C");
value = xmlNodeListGetString (doc, node->xmlChildrenNode, 1);
if (value)
{
@@ -273,6 +277,7 @@ initFloatValue (CompOption::Value &v,
xmlFree (value);
}
+ setlocale (LC_NUMERIC, loc);
}
static void
@@ -623,11 +628,14 @@ initFloatRestriction (CompMetadata *metadata,
const char *path)
{
char *value;
+ char *loc;
float min = MINSHORT;
float max = MAXSHORT;
float precision = 0.1f;
+ loc = setlocale (LC_NUMERIC, NULL);
+ setlocale (LC_NUMERIC, "C");
value = stringFromMetadataPathElement (metadata, path, "min");
if (value)
{
@@ -649,6 +657,8 @@ initFloatRestriction (CompMetadata *metadata,
free (value);
}
r.set (min, max, precision);
+
+ setlocale (LC_NUMERIC, loc);
}
static void