X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Fpage-separators.c;h=e147881730e710e6b70472806a2430c241071efa;hb=7640d70ac1a3641869d8de331594c340c9568ea2;hp=c62c3bb767d25ce81b32acee20fda8f5195ce243;hpb=8aa1c70a718d6d0a0afc16718ceb27af407ad051;p=pspp diff --git a/src/ui/gui/page-separators.c b/src/ui/gui/page-separators.c index c62c3bb767..e147881730 100644 --- a/src/ui/gui/page-separators.c +++ b/src/ui/gui/page-separators.c @@ -16,6 +16,8 @@ #include +#include "page-separators.h" + #include "ui/gui/text-data-import-dialog.h" #include @@ -159,6 +161,7 @@ separators_page_create (struct import_assistant *ia) p->page = add_page_to_assistant (ia, get_widget_assert (builder, "Separators"), GTK_ASSISTANT_PAGE_CONTENT); + p->custom_cb = get_widget_assert (builder, "custom-cb"); p->custom_entry = get_widget_assert (builder, "custom-entry"); p->quote_combo = get_widget_assert (builder, "quote-combo"); @@ -586,3 +589,28 @@ on_separator_toggle (GtkToggleButton *toggle UNUSED, revise_fields_preview (ia); } + + +void +separators_append_syntax (const struct import_assistant *ia, struct string *s) +{ + int i; + ds_put_cstr (s, " /DELIMITERS=\""); + if (ds_find_byte (&ia->separators->separators, '\t') != SIZE_MAX) + ds_put_cstr (s, "\\t"); + if (ds_find_byte (&ia->separators->separators, '\\') != SIZE_MAX) + ds_put_cstr (s, "\\\\"); + for (i = 0; i < ds_length (&ia->separators->separators); i++) + { + char c = ds_at (&ia->separators->separators, i); + if (c == '"') + ds_put_cstr (s, "\"\""); + else if (c != '\t' && c != '\\') + ds_put_byte (s, c); + } + ds_put_cstr (s, "\"\n"); + if (!ds_is_empty (&ia->separators->quotes)) + syntax_gen_pspp (s, " /QUALIFIER=%sq\n", ds_cstr (&ia->separators->quotes)); + if (!ds_is_empty (&ia->separators->quotes) && ia->separators->escape) + ds_put_cstr (s, " /ESCAPE\n"); +}