Damn! Forgot to change casenum_t in *.q
[pspp-builds.git] / src / language / dictionary / numeric.c
index f946e74a4808e61696f4bdcb563fb582904b1ceb..5a1ab18d1f82a2c9a5bc981b45b909921c7c1b6d 100644 (file)
 #include <stdlib.h>
 
 #include <data/dictionary.h>
-#include <procedure.h>
+#include <data/procedure.h>
 #include <data/variable.h>
 #include <language/command.h>
+#include <language/lexer/format-parser.h>
 #include <language/lexer/lexer.h>
-#include <libpspp/message.h>
+#include <language/lexer/variable-parser.h>
+#include <libpspp/assertion.h>
 #include <libpspp/message.h>
 #include <libpspp/str.h>
 
@@ -35,7 +37,7 @@
 
 /* Parses the NUMERIC command. */
 int
-cmd_numeric (void)
+cmd_numeric (struct dataset *ds)
 {
   size_t i;
 
@@ -55,7 +57,7 @@ cmd_numeric (void)
       /* Get the optional format specification. */
       if (lex_match ('('))
        {
-         if (!parse_format_specifier (&f, 0))
+         if (!parse_format_specifier (&f))
            goto fail;
          if (formats[f.type].cat & FCAT_STRING)
            {
@@ -76,7 +78,7 @@ cmd_numeric (void)
       /* Create each variable. */
       for (i = 0; i < nv; i++)
        {
-         struct variable *new_var = dict_create_var (default_dict, v[i], 0);
+         struct variable *new_var = dict_create_var (dataset_dict (ds), v[i], 0);
          if (!new_var)
            msg (SE, _("There is already a variable named %s."), v[i]);
          else
@@ -106,7 +108,7 @@ fail:
 
 /* Parses the STRING command. */
 int
-cmd_string (void)
+cmd_string (struct dataset *ds)
 {
   size_t i;
 
@@ -125,8 +127,7 @@ cmd_string (void)
       if (!parse_DATA_LIST_vars (&v, &nv, PV_NONE))
        return CMD_FAILURE;
 
-      if (!lex_force_match ('(')
-         || !parse_format_specifier (&f, 0))
+      if (!lex_force_match ('(') || !parse_format_specifier (&f))
        goto fail;
       if (!(formats[f.type].cat & FCAT_STRING))
        {
@@ -150,14 +151,13 @@ cmd_string (void)
          width = f.w / 2;
          break;
        default:
-         assert (0);
-          abort ();
+          NOT_REACHED ();
        }
 
       /* Create each variable. */
       for (i = 0; i < nv; i++)
        {
-         struct variable *new_var = dict_create_var (default_dict, v[i],
+         struct variable *new_var = dict_create_var (dataset_dict (ds), v[i],
                                                       width);
          if (!new_var)
            msg (SE, _("There is already a variable named %s."), v[i]);
@@ -185,14 +185,14 @@ fail:
 
 /* Parses the LEAVE command. */
 int
-cmd_leave (void)
+cmd_leave (struct dataset *ds)
 {
   struct variable **v;
   size_t nv;
 
   size_t i;
 
-  if (!parse_variables (default_dict, &v, &nv, PV_NONE))
+  if (!parse_variables (dataset_dict (ds), &v, &nv, PV_NONE))
     return CMD_CASCADING_FAILURE;
   for (i = 0; i < nv; i++)
     v[i]->leave = true;