From 6fe7f1653c376c9668838015216a3d665472d7e5 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 11 Jul 2020 07:40:09 +0200 Subject: [PATCH] psppire-data-window.c (on_cut): Deal properly with string variables. --- src/ui/gui/psppire-data-window.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index db563ba3de..ac5960c9fb 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -1101,20 +1101,25 @@ on_cut (PsppireDataWindow *dw) gtk_clipboard_set_text (clip, str->str, str->len); g_string_free (str, TRUE); - /* Now fill the selected area with SYSMIS */ - union value sm ; - sm.f = SYSMIS; + /* Now fill the selected area with SYSMIS or blanks */ for (x = sel.start_x ; x <= sel.end_x; ++x) { - const struct variable * var = psppire_dict_get_variable (dict, x); + const struct variable *var = psppire_dict_get_variable (dict, x); + int width = var_get_width (var); + union value sm ; + value_init (&sm, width); + if (var_is_numeric (var)) + sm.f = SYSMIS; + else + memset (sm.s, 0, width); for (y = sel.start_y ; y <= sel.end_y; ++y) { psppire_data_store_set_value (dw->data_editor->data_store, y, var, &sm); } + value_destroy (&sm, width); } - } } -- 2.30.2