Added the ability to resize string variables from the GUI. Thanks to
[pspp-builds.git] / src / ui / gui / psppire-case-file.c
index 7de97f5ca2e123df28423a2c5bdfe5915038e9a1..455ac2b755b7d412d89de82cfd6d1d775f7896d1 100644 (file)
@@ -341,25 +341,33 @@ psppire_case_file_sort (PsppireCaseFile *cf, struct case_ordering *ordering)
 
 
 /* Resize the cases in the casefile, by inserting N_VALUES into every
-   one of them. */
+   one of them at the position immediately preceeding WHERE.
+*/
 gboolean
 psppire_case_file_insert_values (PsppireCaseFile *cf,
-                                gint n_values, gint before)
+                                gint n_values, gint where)
 {
-  union value *values;
   g_return_val_if_fail (cf, FALSE);
   g_return_val_if_fail (cf->accessible, FALSE);
 
+  if ( n_values == 0 )
+    return FALSE;
+
+  g_assert (n_values > 0);
+
   if ( ! cf->datasheet )
     cf->datasheet = datasheet_create (NULL);
 
-  values = xcalloc (n_values, sizeof *values);
-  datasheet_insert_columns (cf->datasheet, values, n_values, before);
+  {
+    union value *values = xcalloc (n_values, sizeof *values);
+    datasheet_insert_columns (cf->datasheet, values, n_values, where);
   free (values);
+  }
 
   return TRUE;
 }
 
+
 /* Fills C with the CASENUMth case.
    Returns true on success, false otherwise.
  */