Encapsulated the static data of procedure.[ch] into a single object, to be
[pspp-builds.git] / src / language / dictionary / vector.c
index 9b1eb2cda54bd01257a5064d766f9f66142a3e04..050886d9effd334d203b627e37d6d2e91c6595d4 100644 (file)
    02110-1301, USA. */
 
 #include <config.h>
-#include "message.h"
+
 #include <stdlib.h>
-#include "alloc.h"
-#include "command.h"
-#include "dictionary.h"
-#include "message.h"
-#include "lexer.h"
-#include "misc.h"
-#include "str.h"
-#include "variable.h"
+
+#include <data/procedure.h>
+#include <data/dictionary.h>
+#include <data/variable.h>
+#include <language/command.h>
+#include <language/lexer/lexer.h>
+#include <language/lexer/variable-parser.h>
+#include <libpspp/alloc.h>
+#include <libpspp/assertion.h>
+#include <libpspp/message.h>
+#include <libpspp/misc.h>
+#include <libpspp/str.h>
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -71,7 +75,7 @@ cmd_vector (void)
                goto fail;
              }
 
-         if (dict_lookup_vector (default_dict, tokid))
+         if (dict_lookup_vector (dataset_dict (current_dataset), tokid))
            {
              msg (SE, _("There is already a vector with name %s."), tokid);
              goto fail;
@@ -100,11 +104,11 @@ cmd_vector (void)
              goto fail;
            }
 
-         if (!parse_variables (default_dict, &v, &nv,
+         if (!parse_variables (dataset_dict (current_dataset), &v, &nv,
                                 PV_SAME_TYPE | PV_DUPLICATE))
            goto fail;
 
-          dict_create_vector (default_dict, vecnames, v, nv);
+          dict_create_vector (dataset_dict (current_dataset), vecnames, v, nv);
           free (v);
        }
       else if (lex_match ('('))
@@ -154,7 +158,7 @@ cmd_vector (void)
              for (i = 0; i < nv; i++)
                {
                  sprintf (name, "%s%d", cp, i + 1);
-                 if (dict_lookup_var (default_dict, name))
+                 if (dict_lookup_var (dataset_dict (current_dataset), name))
                    {
                      msg (SE, _("There is already a variable named %s."),
                            name);
@@ -171,10 +175,10 @@ cmd_vector (void)
              for (i = 0; i < nv; i++)
                {
                  sprintf (name, "%s%d", cp, i + 1);
-                 v[i] = dict_create_var_assert (default_dict, name, 0);
+                 v[i] = dict_create_var_assert (dataset_dict (current_dataset), name, 0);
                }
-              if (!dict_create_vector (default_dict, cp, v, nv))
-                assert (0);
+              if (!dict_create_vector (dataset_dict (current_dataset), cp, v, nv))
+                NOT_REACHED ();
              cp += strlen (cp) + 1;
            }
           free (v);
@@ -201,5 +205,5 @@ cmd_vector (void)
 
 fail:
   free (vecnames);
-  return CMD_PART_SUCCESS_MAYBE;
+  return CMD_FAILURE;
 }