Added coefficient-handling routines
[pspp-builds.git] / src / sample.c
index 631736d013f2083259d8b851a62ea76459253268..0255ae79ee21a210411a64c7100a8973acb48a15 100644 (file)
 #include "command.h"
 #include "error.h"
 #include "lexer.h"
-#include "settings.h"
+#include "random.h"
 #include "str.h"
 #include "var.h"
 
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
 #include "debug-print.h"
 
 /* The two different types of samples. */
@@ -42,7 +45,6 @@ enum
 /* SAMPLE transformation. */
 struct sample_trns
   {
-    struct trns_header h;
     int type;                  /* One of TYPE_*. */
     int n, N;                  /* TYPE_A_FROM_B: n from N. */
     int m, t;                  /* TYPE_A_FROM_B: # picked so far; # so far. */
@@ -50,6 +52,7 @@ struct sample_trns
   };
 
 static trns_proc_func sample_trns_proc;
+static trns_free_func sample_trns_free;
 
 int
 cmd_sample (void)
@@ -101,24 +104,22 @@ cmd_sample (void)
   lex_get ();
 
   trns = xmalloc (sizeof *trns);
-  trns->h.proc = sample_trns_proc;
-  trns->h.free = NULL;
   trns->type = type;
   trns->n = a;
   trns->N = b;
   trns->m = trns->t = 0;
   trns->frac = frac;
-  add_transformation ((struct trns_header *) trns);
+  add_transformation (sample_trns_proc, sample_trns_free, trns);
 
   return lex_end_of_command ();
 }
 
 /* Executes a SAMPLE transformation. */
 static int
-sample_trns_proc (struct trns_header * trns, struct ccase *c UNUSED,
+sample_trns_proc (void *t_, struct ccase *c UNUSED,
                   int case_num UNUSED)
 {
-  struct sample_trns *t = (struct sample_trns *) trns;
+  struct sample_trns *t = t_;
   double U;
 
   if (t->type == TYPE_FRACTION) 
@@ -145,3 +146,10 @@ sample_trns_proc (struct trns_header * trns, struct ccase *c UNUSED,
       return -1;
     }
 }
+
+static void
+sample_trns_free (void *t_) 
+{
+  struct sample_trns *t = t_;
+  free (t);
+}