Eliminated global variable current_dataset.
[pspp-builds.git] / src / language / dictionary / formats.c
index c325b4082e40a897980d123217e0fcf4323aa3a9..995ee3fb0d9b427e61985114f920241634f31a61 100644 (file)
    02110-1301, USA. */
 
 #include <config.h>
+
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
+
+#include <data/procedure.h>
+#include <data/variable.h>
 #include <language/command.h>
-#include <libpspp/message.h>
+#include <language/lexer/format-parser.h>
 #include <language/lexer/lexer.h>
+#include <language/lexer/variable-parser.h>
+#include <libpspp/message.h>
 #include <libpspp/misc.h>
 #include <libpspp/str.h>
-#include <data/variable.h>
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -37,28 +42,28 @@ enum
     FORMATS_WRITE = 002
   };
 
-static int internal_cmd_formats (int);
+static int internal_cmd_formats (struct dataset *ds, int);
 
 int
-cmd_print_formats (void)
+cmd_print_formats (struct dataset *ds)
 {
-  return internal_cmd_formats (FORMATS_PRINT);
+  return internal_cmd_formats (ds, FORMATS_PRINT);
 }
 
 int
-cmd_write_formats (void)
+cmd_write_formats (struct dataset *ds)
 {
-  return internal_cmd_formats (FORMATS_WRITE);
+  return internal_cmd_formats (ds, FORMATS_WRITE);
 }
 
 int
-cmd_formats (void)
+cmd_formats (struct dataset *ds)
 {
-  return internal_cmd_formats (FORMATS_PRINT | FORMATS_WRITE);
+  return internal_cmd_formats (ds, FORMATS_PRINT | FORMATS_WRITE);
 }
 
-int
-internal_cmd_formats (int which)
+static int
+internal_cmd_formats (struct dataset *ds, int which)
 {
   /* Variables. */
   struct variable **v;
@@ -78,16 +83,16 @@ internal_cmd_formats (int which)
       if (token == '.')
        break;
 
-      if (!parse_variables (default_dict, &v, &cv, PV_NUMERIC))
+      if (!parse_variables (dataset_dict (ds), &v, &cv, PV_NUMERIC))
        return CMD_FAILURE;
       type = v[0]->type;
 
       if (!lex_match ('('))
        {
-         msg (SE, _("`(' expected after variable list"));
+         msg (SE, _("`(' expected after variable list."));
          goto fail;
        }
-      if (!parse_format_specifier (&f, 0)
+      if (!parse_format_specifier (&f)
           || !check_output_specifier (&f, true)
           || !check_specifier_type (&f, NUMERIC, true))
        goto fail;