X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Ftext-data-import-dialog.c;h=4db2d8ca6fe88432c9872ced331c281fd29a211e;hb=d8493b3b0617cc447446a70b031a69079bc19002;hp=070c4f6b3cd3b05b3428994cb307326463599a6c;hpb=4e8efdc4acb80fc1a3735228d29fca0cf86fee6d;p=pspp diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c index 070c4f6b3c..4db2d8ca6f 100644 --- a/src/ui/gui/text-data-import-dialog.c +++ b/src/ui/gui/text-data-import-dialog.c @@ -338,7 +338,7 @@ apply_dict (const struct dictionary *dict, struct string *s) const struct val_lab *vl = labels[i]; ds_put_cstr (s, "\n "); syntax_gen_value (s, &vl->value, width, format); - ds_put_char (s, ' '); + ds_put_byte (s, ' '); syntax_gen_string (s, ss_cstr (val_lab_get_label (vl))); } free (labels); @@ -398,9 +398,9 @@ generate_syntax (const struct import_assistant *ia) if (ia->first_line.skip_lines > 0) ds_put_format (&s, " /FIRSTCASE=%d\n", ia->first_line.skip_lines + 1); ds_put_cstr (&s, " /DELIMITERS=\""); - if (ds_find_char (&ia->separators.separators, '\t') != SIZE_MAX) + if (ds_find_byte (&ia->separators.separators, '\t') != SIZE_MAX) ds_put_cstr (&s, "\\t"); - if (ds_find_char (&ia->separators.separators, '\\') != SIZE_MAX) + if (ds_find_byte (&ia->separators.separators, '\\') != SIZE_MAX) ds_put_cstr (&s, "\\\\"); for (i = 0; i < ds_length (&ia->separators.separators); i++) { @@ -408,7 +408,7 @@ generate_syntax (const struct import_assistant *ia) if (c == '"') ds_put_cstr (&s, "\"\""); else if (c != '\t' && c != '\\') - ds_put_char (&s, c); + ds_put_byte (&s, c); } ds_put_cstr (&s, "\"\n"); if (!ds_is_empty (&ia->separators.quotes)) @@ -1169,7 +1169,7 @@ split_fields (struct import_assistant *ia) clear_fields (ia); /* Is space in the set of separators? */ - space_sep = ss_find_char (ds_ss (&s->separators), ' ') != SIZE_MAX; + space_sep = ss_find_byte (ds_ss (&s->separators), ' ') != SIZE_MAX; /* Split all the lines, not just those from ia->first_line.skip_lines on, so that we split the line that @@ -1196,9 +1196,9 @@ split_fields (struct import_assistant *ia) field = text; } else if (!ds_is_empty (&s->quotes) - && ds_find_char (&s->quotes, text.string[0]) != SIZE_MAX) + && ds_find_byte (&s->quotes, text.string[0]) != SIZE_MAX) { - int quote = ss_get_char (&text); + int quote = ss_get_byte (&text); if (!s->escape) ss_get_until (&text, quote, &field); else @@ -1207,18 +1207,18 @@ split_fields (struct import_assistant *ia) int c; ds_init_empty (&s); - while ((c = ss_get_char (&text)) != EOF) + while ((c = ss_get_byte (&text)) != EOF) if (c != quote) - ds_put_char (&s, c); - else if (ss_match_char (&text, quote)) - ds_put_char (&s, quote); + ds_put_byte (&s, c); + else if (ss_match_byte (&text, quote)) + ds_put_byte (&s, quote); else break; field = ds_ss (&s); } } else - ss_get_chars (&text, ss_cspan (text, ds_ss (&s->separators)), + ss_get_bytes (&text, ss_cspan (text, ds_ss (&s->separators)), &field); if (column_idx >= s->column_cnt) @@ -1243,7 +1243,7 @@ split_fields (struct import_assistant *ia) ss_ltrim (&text, ss_cstr (" ")); if (ss_is_empty (text)) break; - if (ss_find_char (ds_ss (&s->separators), ss_first (text)) + if (ss_find_byte (ds_ss (&s->separators), ss_first (text)) != SIZE_MAX) ss_advance (&text, 1); } @@ -1331,7 +1331,7 @@ find_commonest_chars (unsigned long int histogram[UCHAR_MAX + 1], if (max_count > 0) { ds_clear (result); - ds_put_char (result, max); + ds_put_byte (result, max); } else ds_assign_cstr (result, def); @@ -1387,7 +1387,7 @@ set_separators (struct import_assistant *ia) } } - ds_put_char (&custom, c); + ds_put_byte (&custom, c); next:; } @@ -1430,7 +1430,7 @@ get_separators (struct import_assistant *ia) const struct separator *sep = &separators[i]; GtkWidget *button = get_widget_assert (ia->asst.builder, sep->name); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) - ds_put_char (&s->separators, sep->c); + ds_put_byte (&s->separators, sep->c); } if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (s->custom_cb))) @@ -1775,19 +1775,19 @@ parse_field (struct import_assistant *ia, tooltip = NULL; if (field.string != NULL) { - msg_disable (); + char *error; - if (!data_in (field, LEGACY_NATIVE, in->type, 0, 0, ia->formats.dict, - &val, var_get_width (var))) + error = data_in (field, LEGACY_NATIVE, in->type, &val, + var_get_width (var), + dict_get_encoding (ia->formats.dict)); + if (error != NULL) { - char fmt_string[FMT_STRING_LEN_MAX + 1]; - fmt_to_string (in, fmt_string); - tooltip = xasprintf (_("Field content `%.*s' cannot be parsed in " - "format %s."), + tooltip = xasprintf (_("Cannot parse field content `%.*s' as " + "format %s: %s"), (int) field.length, field.string, - fmt_string); + fmt_name (in->type), error); + free (error); } - msg_enable (); } else { @@ -1952,8 +1952,8 @@ get_monospace_width (GtkTreeView *treeview, GtkCellRenderer *renderer, gint width; ds_init_empty (&s); - ds_put_char_multiple (&s, '0', char_cnt); - ds_put_char (&s, ' '); + ds_put_byte_multiple (&s, '0', char_cnt); + ds_put_byte (&s, ' '); width = get_string_width (treeview, renderer, ds_cstr (&s)); ds_destroy (&s);