psppire-data-window.c (on_cut): Deal properly with string variables.
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 11 Jul 2020 05:40:09 +0000 (07:40 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 11 Jul 2020 05:40:09 +0000 (07:40 +0200)
src/ui/gui/psppire-data-window.c

index db563ba3de89b7f5cb505fa4d843e4a788d4e627..ac5960c9fb96366f747152c4b8807ad0330ff23a 100644 (file)
@@ -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);
        }
-
     }
 }