diff options
author | David Robillard <d@drobilla.net> | 2011-12-19 03:04:05 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-12-19 03:04:05 +0000 |
commit | b760711088bb027d7c84eec7c19360d8f02680ec (patch) | |
tree | 97980f45935fc160171f0e9b28844d4959708bfe | |
parent | a12728f443694420b2d4e7a9307d738513cef24f (diff) | |
download | lilv-b760711088bb027d7c84eec7c19360d8f02680ec.tar.gz lilv-b760711088bb027d7c84eec7c19360d8f02680ec.tar.bz2 lilv-b760711088bb027d7c84eec7c19360d8f02680ec.zip |
Remove locale smashing kludges and use new serd functions for converting nodes
to/from numbers.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3891 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/node.c | 41 | ||||
-rw-r--r-- | utils/lv2info.c | 2 | ||||
-rw-r--r-- | wscript | 2 |
4 files changed, 12 insertions, 35 deletions
@@ -14,6 +14,8 @@ lilv (UNRELEASED) unstable; urgency=low are not directly rdfs:seeAlso linked (e.g. presets) * Add lilv_world_load_resource for related resources (e.g. presets) * Print presets in lv2info + * Remove locale smashing kludges and use new serd functions for converting + nodes to/from numbers. -- David Robillard <d@drobilla.net> (UNRELEASED) @@ -15,7 +15,6 @@ */ #include <assert.h> -#include <locale.h> #include <stdlib.h> #include <string.h> @@ -24,7 +23,6 @@ static void lilv_node_set_numerics_from_string(LilvNode* val) { - char* locale; char* endptr; switch (val->type) { @@ -33,20 +31,10 @@ lilv_node_set_numerics_from_string(LilvNode* val) case LILV_VALUE_STRING: break; case LILV_VALUE_INT: - // FIXME: locale kludge, need a locale independent strtol - locale = lilv_strdup(setlocale(LC_NUMERIC, NULL)); - setlocale(LC_NUMERIC, "POSIX"); val->val.int_val = strtol(val->str_val, &endptr, 10); - setlocale(LC_NUMERIC, locale); - free(locale); break; case LILV_VALUE_FLOAT: - // FIXME: locale kludge, need a locale independent strtod - locale = lilv_strdup(setlocale(LC_NUMERIC, NULL)); - setlocale(LC_NUMERIC, "POSIX"); - val->val.float_val = strtod(val->str_val, &endptr); - setlocale(LC_NUMERIC, locale); - free(locale); + val->val.float_val = serd_strtod(val->str_val, &endptr); break; case LILV_VALUE_BOOL: val->val.bool_val = (!strcmp(val->str_val, "true")); @@ -258,9 +246,9 @@ LILV_API char* lilv_node_get_turtle_token(const LilvNode* value) { - size_t len = 0; - char* result = NULL; - char* locale = NULL; + size_t len = 0; + char* result = NULL; + SerdNode node; switch (value->type) { case LILV_VALUE_URI: @@ -278,28 +266,15 @@ lilv_node_get_turtle_token(const LilvNode* value) result = lilv_strdup(value->str_val); break; case LILV_VALUE_INT: - // INT64_MAX is 9223372036854775807 (19 digits) + 1 for sign - // FIXME: locale kludge, need a locale independent snprintf - locale = lilv_strdup(setlocale(LC_NUMERIC, NULL)); - len = 20; - result = calloc(len, 1); - setlocale(LC_NUMERIC, "POSIX"); - snprintf(result, len, "%d", value->val.int_val); - setlocale(LC_NUMERIC, locale); + node = serd_node_new_integer(value->val.int_val); + result = (char*)node.buf; break; case LILV_VALUE_FLOAT: - // FIXME: locale kludge, need a locale independent snprintf - locale = lilv_strdup(setlocale(LC_NUMERIC, NULL)); - len = 20; // FIXME: proper maximum value? - result = calloc(len, 1); - setlocale(LC_NUMERIC, "POSIX"); - snprintf(result, len, "%f", value->val.float_val); - setlocale(LC_NUMERIC, locale); + node = serd_node_new_decimal(value->val.float_val, 8); + result = (char*)node.buf; break; } - free(locale); - return result; } diff --git a/utils/lv2info.c b/utils/lv2info.c index 7f231f3..e152bfe 100644 --- a/utils/lv2info.c +++ b/utils/lv2info.c @@ -14,7 +14,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <locale.h> #include <math.h> #include <stdio.h> #include <stdlib.h> @@ -378,7 +377,6 @@ main(int argc, char** argv) } int ret = 0; - setlocale(LC_ALL, ""); LilvWorld* world = lilv_world_new(); lilv_world_load_all(world); @@ -67,6 +67,8 @@ def configure(conf): autowaf.display_header('Lilv Configuration') autowaf.check_pkg(conf, 'lv2core', uselib_store='LV2CORE', mandatory=True) + autowaf.check_pkg(conf, 'serd-0', uselib_store='SERD', + atleast_version='0.7.0', mandatory=True) autowaf.check_pkg(conf, 'sord-0', uselib_store='SORD', atleast_version='0.5.0', mandatory=True) |