2 #include "var-display.h"
4 #include <data/variable.h>
5 #include <data/format.h>
9 #define _(msgid) gettext (msgid)
10 #define N_(msgid) msgid
14 const static gchar none[] = N_("None");
17 name_to_string (const struct variable *var, GError **err)
19 const char *name = var_get_name (var);
22 return pspp_locale_to_utf8 (name, -1, err);
27 label_to_string (const struct variable *var, GError **err)
29 const char *label = var_get_label (var);
31 if ( ! label ) return g_strdup (none);
33 return pspp_locale_to_utf8 (label, -1, err);
37 measure_to_string (const struct variable *var, GError **err)
39 const gint measure = var_get_measure (var);
41 g_assert (measure < n_MEASURES);
42 return g_locale_to_utf8 (gettext (measures[measure]),
48 missing_values_to_string (const struct variable *pv, GError **err)
50 const struct fmt_spec *fmt = var_get_print_format (pv);
52 const struct missing_values *miss = var_get_missing_values (pv);
53 if ( mv_is_empty (miss))
54 return g_locale_to_utf8 (gettext (none), -1, 0, 0, err);
57 if ( ! mv_has_range (miss))
59 GString *gstr = g_string_sized_new (10);
60 const int n = mv_n_values (miss);
61 gchar *mv[4] = {0,0,0,0};
63 for (i = 0 ; i < n; ++i )
66 mv_get_value (miss, &v, i);
67 mv[i] = value_to_text (v, *fmt);
69 g_string_append (gstr, ", ");
70 g_string_append (gstr, mv[i]);
73 s = pspp_locale_to_utf8 (gstr->str, gstr->len, err);
74 g_string_free (gstr, TRUE);
78 GString *gstr = g_string_sized_new (10);
80 union value low, high;
81 mv_get_range (miss, &low.f, &high.f);
83 l = value_to_text (low, *fmt);
84 h = value_to_text (high, *fmt);
86 g_string_printf (gstr, "%s - %s", l, h);
90 if ( mv_has_value (miss))
94 mv_get_value (miss, &v, 0);
96 ss = value_to_text (v, *fmt);
98 g_string_append (gstr, ", ");
99 g_string_append (gstr, ss);
102 s = pspp_locale_to_utf8 (gstr->str, gstr->len, err);
103 g_string_free (gstr, TRUE);