First step in making struct variable opaque: the boring mechanical
[pspp-builds.git] / src / language / stats / sort-criteria.c
index 5bc26d9abfae6b1b89f06ede6904b994b1c9c0b1..6e8bada48e01653f7d6d08b53ca714e66a6d30ae 100644 (file)
 #include <assert.h>
 #include <stdlib.h>
 #include <limits.h>
-#include "alloc.h"
-#include "command.h"
-#include "message.h"
-#include "lexer.h"
-#include "settings.h"
-#include "variable.h"
+#include <libpspp/alloc.h>
+#include <language/command.h>
+#include <libpspp/message.h>
+#include <language/lexer/lexer.h>
+#include <language/lexer/variable-parser.h>
+#include <data/settings.h>
+#include <data/variable.h>
 #include "sort-criteria.h"
-#include "sort.h"
+#include <math/sort.h>
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -49,7 +50,7 @@ static bool  is_terminator(int tok, const int *terminators);
    
 */
 struct sort_criteria *
-sort_parse_criteria (const struct dictionary *dict,
+sort_parse_criteria (struct lexer *lexer, const struct dictionary *dict,
                      struct variable ***vars, size_t *var_cnt,
                      bool *saw_direction,
                     const int *terminators
@@ -81,23 +82,23 @@ sort_parse_criteria (const struct dictionary *dict,
       enum sort_direction direction;
 
       /* Variables. */
-      if (!parse_variables (dict, vars, var_cnt,
+      if (!parse_variables (lexer, dict, vars, var_cnt,
                            PV_NO_DUPLICATE | PV_APPEND | PV_NO_SCRATCH))
         goto error;
 
       /* Sort direction. */
-      if (lex_match ('('))
+      if (lex_match (lexer, '('))
        {
-         if (lex_match_id ("D") || lex_match_id ("DOWN"))
+         if (lex_match_id (lexer, "D") || lex_match_id (lexer, "DOWN"))
            direction = SRT_DESCEND;
-         else if (lex_match_id ("A") || lex_match_id ("UP"))
+         else if (lex_match_id (lexer, "A") || lex_match_id (lexer, "UP"))
             direction = SRT_ASCEND;
           else
            {
              msg (SE, _("`A' or `D' expected inside parentheses."));
               goto error;
            }
-         if (!lex_match (')'))
+         if (!lex_match (lexer, ')'))
            {
              msg (SE, _("`)' expected."));
               goto error;
@@ -115,11 +116,11 @@ sort_parse_criteria (const struct dictionary *dict,
         {
           struct sort_criterion *c = &criteria->crits[prev_var_cnt];
           c->fv = (*vars)[prev_var_cnt]->fv;
-          c->width = (*vars)[prev_var_cnt]->width;
+          c->width = var_get_width ((*vars)[prev_var_cnt]);
           c->dir = direction;
         }
     }
-  while (token != '.' && token != '/' && !is_terminator(token, terminators));
+  while (lex_token (lexer) != '.' && lex_token (lexer) != '/' && !is_terminator(lex_token (lexer), terminators));
 
   free (local_vars);
   return criteria;