Update all #include directives to the currently preferred style.
[pspp-builds.git] / src / math / order-stats.c
index 1b6aa131ea745ba6c0b55b33a54f3a6d39ceddbe..be9c49a3122171b6f1eee792a802e080ab2f4150 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2008, 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
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <config.h>
-#include "order-stats.h"
-#include <libpspp/assertion.h>
-#include <data/val-type.h>
-#include <gl/xalloc.h>
-#include <data/variable.h>
-#include <data/casereader.h>
+
+#include "math/order-stats.h"
+
 #include <string.h>
 
+#include "data/casereader.h"
+#include "data/val-type.h"
+#include "data/variable.h"
+#include "libpspp/assertion.h"
+
+#include "gl/xalloc.h"
+
 #if 0
 
 #include <stdio.h>
@@ -90,7 +94,7 @@ update_k_values (const struct ccase *cx, double y_i, double c_i, double cc_i,
     {
       int k;
       struct order_stats *tos = os[j];
-      struct statistic  *stat = (struct statistic *) tos;
+      struct statistic  *stat = &tos->parent;
       for (k = 0 ; k < tos->n_k; ++k)
        {
          struct k *myk = &tos->k[k];
@@ -131,8 +135,6 @@ order_stats_accumulate (struct order_stats **os, size_t nos,
       if ( var_is_value_missing (var, case_data (cx, var), exclude))
        continue;
 
-      case_unref (prev_cx);
-
       if ( prev_value == -DBL_MAX || prev_value == this_value)
        c_i += weight;
 
@@ -142,6 +144,7 @@ order_stats_accumulate (struct order_stats **os, size_t nos,
          c_i = weight;
        }
 
+      case_unref (prev_cx);
       cc_i += weight;
       prev_value = this_value;
       prev_cx = case_ref (cx);