Change license from GPLv2+ to GPLv3+.
[pspp-builds.git] / src / ui / gui / psppire-case-file.c
index ee31c013c33de76c16817fa679708ec1d4cf0ee1..2401be4a27c501f9b2fa8ec44d3308491fde8a37 100644 (file)
@@ -1,21 +1,18 @@
-/*
-    PSPPIRE --- A Graphical User Interface for PSPP
-    Copyright (C) 2006  Free Software Foundation
+/* PSPPIRE - a graphical user interface for PSPP.
+   Copyright (C) 2006  Free Software Foundation
 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-    02110-1301, USA. */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <config.h>
 #include <string.h>
 #include <data/case.h>
 #include <data/data-in.h>
 #include <data/datasheet.h>
+#include <data/casereader.h>
 #include <math/sort.h>
 #include <libpspp/misc.h>
 
 #include "xalloc.h"
-#include "xallocsa.h"
+#include "xmalloca.h"
 
 /* --- prototypes --- */
 static void psppire_case_file_class_init       (PsppireCaseFileClass   *class);
@@ -93,7 +91,7 @@ psppire_case_file_class_init (PsppireCaseFileClass *class)
   object_class->finalize = psppire_case_file_finalize;
 
   signals [CASE_CHANGED] =
-    g_signal_new ("case_changed",
+    g_signal_new ("case-changed",
                  G_TYPE_FROM_CLASS (class),
                  G_SIGNAL_RUN_FIRST,
                  0,
@@ -105,7 +103,7 @@ psppire_case_file_class_init (PsppireCaseFileClass *class)
 
 
   signals [CASE_INSERTED] =
-    g_signal_new ("case_inserted",
+    g_signal_new ("case-inserted",
                  G_TYPE_FROM_CLASS (class),
                  G_SIGNAL_RUN_FIRST,
                  0,
@@ -117,7 +115,7 @@ psppire_case_file_class_init (PsppireCaseFileClass *class)
 
 
   signals [CASES_DELETED] =
-    g_signal_new ("cases_deleted",
+    g_signal_new ("cases-deleted",
                  G_TYPE_FROM_CLASS (class),
                  G_SIGNAL_RUN_FIRST,
                  0,
@@ -154,11 +152,11 @@ psppire_case_file_init (PsppireCaseFile *cf)
  * Creates a new #PsppireCaseFile.
  */
 PsppireCaseFile*
-psppire_case_file_new (struct casereader *reader)
+psppire_case_file_new (const struct casereader *reader)
 {
   PsppireCaseFile *cf = g_object_new (G_TYPE_PSPPIRE_CASE_FILE, NULL);
 
-  cf->datasheet = datasheet_create (reader);
+  cf->datasheet = datasheet_create (casereader_clone (reader));
   cf->accessible = TRUE;
 
   return cf;
@@ -312,7 +310,7 @@ psppire_case_file_data_in (PsppireCaseFile *cf, gint casenum, gint idx,
   g_return_val_if_fail (idx < datasheet_get_column_cnt (cf->datasheet), FALSE);
 
   width = fmt_var_width (fmt);
-  value = xallocsa (value_cnt_from_width (width) * sizeof *value);
+  value = xmalloca (value_cnt_from_width (width) * sizeof *value);
   ok = (datasheet_get_value (cf->datasheet, casenum, idx, value, width)
         && data_in (input, fmt->type, 0, 0, value, width)
         && datasheet_put_value (cf->datasheet, casenum, idx, value, width));
@@ -320,7 +318,7 @@ psppire_case_file_data_in (PsppireCaseFile *cf, gint casenum, gint idx,
   if (ok)
     g_signal_emit (cf, signals [CASE_CHANGED], 0, casenum);
 
-  freesa (value);
+  freea (value);
 
   return TRUE;
 }