Work on support for variable sets.
[pspp] / src / data / casereader-project.c
index 116a3359b4408caf2a51912a45095ea3ffb5843d..55a8993bab93f297bd84855caade6f9dd3fe239a 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2011 Free Software Foundation, Inc.
 
    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
@@ -16,8 +16,8 @@
 
 #include <config.h>
 
-#include <data/casereader-provider.h>
-#include <data/subcase.h>
+#include "data/casereader-provider.h"
+#include "data/subcase.h"
 
 #include "gl/xalloc.h"
 
@@ -44,7 +44,7 @@ struct casereader_project
   };
 
 static struct ccase *
-project_case (struct ccase *old, casenumber idx UNUSED, const void *project_)
+project_case (struct ccase *old, void *project_)
 {
   const struct casereader_project *project = project_;
   struct ccase *new = case_create (subcase_get_proto (&project->new_sc));
@@ -57,8 +57,8 @@ static bool
 destroy_projection (void *project_)
 {
   struct casereader_project *project = project_;
-  subcase_destroy (&project->old_sc);
-  subcase_destroy (&project->new_sc);
+  subcase_uninit (&project->old_sc);
+  subcase_uninit (&project->new_sc);
   free (project);
   return true;
 }
@@ -81,9 +81,12 @@ casereader_project (struct casereader *subreader, const struct subcase *sc)
       subcase_init_empty (&project->new_sc);
       subcase_add_proto_always (&project->new_sc, proto);
 
+      static const struct casereader_translator_class class = {
+        project_case, destroy_projection,
+      };
+
       return casereader_translate_stateless (subreader, proto,
-                                             project_case, destroy_projection,
-                                             project);
+                                             &class, project);
     }
 }
 
@@ -99,7 +102,7 @@ casereader_project_1 (struct casereader *subreader, int column)
   subcase_init (&sc, column, caseproto_get_width (subproto, column),
                 SC_ASCEND);
   reader = casereader_project (subreader, &sc);
-  subcase_destroy (&sc);
+  subcase_uninit (&sc);
 
   return reader;
 }