Finish converting struct variable to an opaque type. In this
[pspp] / src / math / sort.c
index 0d32d5ccccfb0a37fca04391626ad9db6a37ff5f..fbd40d9b966897ec4df1afd7e53e7916e8dec022 100644 (file)
@@ -35,7 +35,6 @@
 #include <data/settings.h>
 #include <data/variable.h>
 #include <data/storage-stream.h>
-#include <language/expressions/public.h>
 #include <libpspp/alloc.h>
 #include <libpspp/array.h>
 #include <libpspp/assertion.h>
@@ -44,6 +43,8 @@
 #include <libpspp/misc.h>
 #include <libpspp/str.h>
 
+#include "minmax.h"
+
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
 
@@ -93,7 +94,7 @@ static bool
 sort_to_casefile_callback (const struct casefile *cf, void *cb_data_) 
 {
   struct sort_to_casefile_cb_data *cb_data = cb_data_;
-  cb_data->output = sort_execute (casefile_get_reader (cf), cb_data->criteria);
+  cb_data->output = sort_execute (casefile_get_reader (cf, NULL), cb_data->criteria);
   return cb_data->output != NULL;
 }
 
@@ -462,13 +463,14 @@ compare_record (const struct ccase *a, const struct ccase *b,
       
       if (c->width == 0)
         {
-          double af = case_num (a, c->fv);
-          double bf = case_num (b, c->fv);
+          double af = case_num_idx (a, c->fv);
+          double bf = case_num_idx (b, c->fv);
           
           result = af < bf ? -1 : af > bf;
         }
       else
-        result = memcmp (case_str (a, c->fv), case_str (b, c->fv), c->width);
+        result = memcmp (case_str_idx (a, c->fv),
+                         case_str_idx (b, c->fv), c->width);
 
       if (result != 0)
         return c->dir == SRT_ASCEND ? result : -result;
@@ -587,7 +589,7 @@ merge (struct external_sort *xsrt)
 {
   while (xsrt->run_cnt > 1)
     {
-      int order = min (MAX_MERGE_ORDER, xsrt->run_cnt);
+      int order = MIN (MAX_MERGE_ORDER, xsrt->run_cnt);
       int idx = choose_merge (xsrt->runs, xsrt->run_cnt, order);
       xsrt->runs[idx] = merge_once (xsrt, xsrt->runs + idx, order);
       remove_range (xsrt->runs, xsrt->run_cnt, sizeof *xsrt->runs,