2 #include "var-display.h"
4 #include <data/variable.h>
5 #include <data/format.h>
7 #include "psppire-dict.h"
10 #define _(msgid) gettext (msgid)
11 #define N_(msgid) msgid
14 #include <libpspp/i18n.h>
16 static const gchar none[] = N_("None");
20 measure_to_string (const struct variable *var, GError **err)
22 const gint measure = var_get_measure (var);
24 g_assert (measure < n_MEASURES);
25 return g_locale_to_utf8 (gettext (measures[measure]),
31 missing_values_to_string (const PsppireDict *dict, const struct variable *pv, GError **err)
33 const struct fmt_spec *fmt = var_get_print_format (pv);
35 const struct missing_values *miss = var_get_missing_values (pv);
36 if ( mv_is_empty (miss))
37 return g_locale_to_utf8 (gettext (none), -1, 0, 0, err);
40 if ( ! mv_has_range (miss))
42 GString *gstr = g_string_sized_new (10);
43 const int n = mv_n_values (miss);
44 gchar *mv[4] = {0,0,0,0};
46 for (i = 0 ; i < n; ++i )
48 mv[i] = value_to_text (*mv_get_value (miss, i), *fmt);
50 g_string_append (gstr, ", ");
51 g_string_append (gstr, mv[i]);
54 s = recode_string (UTF8, psppire_dict_encoding (dict),
55 gstr->str, gstr->len);
56 g_string_free (gstr, TRUE);
60 GString *gstr = g_string_sized_new (10);
62 union value low, high;
63 mv_get_range (miss, &low.f, &high.f);
65 l = value_to_text (low, *fmt);
66 h = value_to_text (high, *fmt);
68 g_string_printf (gstr, "%s - %s", l, h);
72 if ( mv_has_value (miss))
76 ss = value_to_text (*mv_get_value (miss, 0), *fmt);
78 g_string_append (gstr, ", ");
79 g_string_append (gstr, ss);
82 s = recode_string (UTF8, psppire_dict_encoding (dict),
83 gstr->str, gstr->len);
84 g_string_free (gstr, TRUE);