From 1221be814f2f1d67c49849512e0938b059a58009 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 7 Jul 2009 19:24:40 +0800 Subject: [PATCH] Fix problem running the perl module --- perl-module/PSPP.xs | 7 ++++++- src/libpspp/i18n.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/perl-module/PSPP.xs b/perl-module/PSPP.xs index e80b3cf2..d10cc349 100644 --- a/perl-module/PSPP.xs +++ b/perl-module/PSPP.xs @@ -38,9 +38,11 @@ #include #include #include +#include #include #include #include +#include #include typedef struct fmt_spec input_format ; @@ -163,6 +165,7 @@ onBoot (ver) const char *ver CODE: assert (0 == strcmp (ver, bare_version)); + i18n_init (); msg_init (NULL, message_handler); settings_init (0, 0); fh_init (); @@ -174,10 +177,12 @@ format_value (val, var) CODE: SV *ret; const struct fmt_spec *fmt = var_get_print_format (var); + const struct dictionary *dict = var_get_vardict (var)->dict; union value uv; char *s; make_value_from_scalar (&uv, val, var); - s = data_out (&uv, fmt); + fprintf (stderr, "Encoding is %s\n", dict_get_encoding (dict)); + s = data_out (&uv, dict_get_encoding (dict), fmt); value_destroy (&uv, var_get_width (var)); ret = newSVpv (s, fmt->w); free (s); diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index d443619a..e08ba280 100644 --- a/src/libpspp/i18n.c +++ b/src/libpspp/i18n.c @@ -94,7 +94,8 @@ recode_string (const char *to, const char *from, } -/* Return a string based on TEXT converted according to HOW. +/* Return a string based on TEXT which must be encoded using FROM. + The returned string will be encoded in TO. If length is not -1, then it must be the number of bytes in TEXT. The returned string must be freed when no longer required. */ @@ -119,7 +120,6 @@ recode_string_pool (const char *to, const char *from, if ( length == -1 ) length = strlen(text); - if (to == NULL) to = default_encoding; -- 2.30.2