X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Ftext-data-import-dialog.c;h=6f33ff6d8bb8b6547a76a91bc06d35260a3a1881;hb=ff59ee87992b440aab8083ee041f9aecd2ce68ca;hp=c674f17d1e1cd9279cdb472ae7e4d0ea6398d361;hpb=14aac9fe7a7efbb6c9bded2ed5969a643cb76645;p=pspp-builds.git diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c index c674f17d..6f33ff6d 100644 --- a/src/ui/gui/text-data-import-dialog.c +++ b/src/ui/gui/text-data-import-dialog.c @@ -310,11 +310,9 @@ apply_dict (const struct dictionary *dict, struct string *s) syntax_gen_pspp (s, "MISSING VALUES %ss (", name); for (j = 0; j < mv_n_values (mv); j++) { - union value value; if (j) ds_put_cstr (s, ", "); - mv_get_value (mv, &value, j); - syntax_gen_value (s, &value, width, format); + syntax_gen_value (s, mv_get_value (mv, j), width, format); } if (mv_has_range (mv)) @@ -330,18 +328,20 @@ apply_dict (const struct dictionary *dict, struct string *s) if (var_has_value_labels (var)) { const struct val_labs *vls = var_get_value_labels (var); - struct val_labs_iterator *iter; - struct val_lab *vl; + const struct val_lab **labels = val_labs_sorted (vls); + size_t n_labels = val_labs_count (vls); + size_t i; syntax_gen_pspp (s, "VALUE LABELS %ss", name); - for (vl = val_labs_first_sorted (vls, &iter); vl != NULL; - vl = val_labs_next (vls, &iter)) + for (i = 0; i < n_labels; i++) { + const struct val_lab *vl = labels[i]; ds_put_cstr (s, "\n "); syntax_gen_value (s, &vl->value, width, format); ds_put_char (s, ' '); - syntax_gen_string (s, ss_cstr (vl->label)); + syntax_gen_string (s, ss_cstr (val_lab_get_label (vl))); } + free (labels); ds_put_cstr (s, ".\n"); } if (var_has_label (var)) @@ -1543,6 +1543,7 @@ init_formats_page (struct import_assistant *ia) p->data_tree_view = GTK_TREE_VIEW (get_widget_assert (builder, "data")); p->modified_vars = NULL; p->modified_var_cnt = 0; + p->dict = NULL; } /* Frees IA's formats substructure. */ @@ -1732,7 +1733,7 @@ parse_field (struct import_assistant *ia, char **outputp, char **tooltipp) { struct substring field; - union value *val; + union value val; struct variable *var; const struct fmt_spec *in; struct fmt_spec out; @@ -1741,15 +1742,17 @@ parse_field (struct import_assistant *ia, field = ia->separators.columns[column].contents[row]; var = dict_get_var (ia->formats.dict, column); - val = value_create (var_get_width (var)); + value_init (&val, var_get_width (var)); in = var_get_print_format (var); out = fmt_for_output_from_input (in); tooltip = NULL; if (field.string != NULL) { msg_disable (); + if (!data_in (field, LEGACY_NATIVE, in->type, 0, 0, 0, - val, var_get_width (var))) + ia->formats.dict, + &val, var_get_width (var))) { char fmt_string[FMT_STRING_LEN_MAX + 1]; fmt_to_string (in, fmt_string); @@ -1764,16 +1767,13 @@ parse_field (struct import_assistant *ia, { tooltip = xstrdup (_("This input line has too few separators " "to fill in this field.")); - value_set_missing (val, var_get_width (var)); + value_set_missing (&val, var_get_width (var)); } if (outputp != NULL) { - char *output = xmalloc (out.w + 1); - data_out (val, &out, output); - output[out.w] = '\0'; - *outputp = output; + *outputp = data_out (&val, dict_get_encoding (ia->formats.dict), &out); } - free (val); + value_destroy (&val, var_get_width (var)); ok = tooltip == NULL; if (tooltipp != NULL)