Finish converting struct variable to an opaque type. In this
[pspp] / src / math / sort.c
index 9f5e5fb956a4c94f31f78bd03139c78fd3742126..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)
 
@@ -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,