Implemented long variable names a la spss V12.
[pspp-builds.git] / src / vector.c
index e63ac2153f6166eef9d1dcc0694ab539ac9308bc..9a0d749265529f92332a2877feb5a1ad1db9c225 100644 (file)
    02111-1307, USA. */
 
 #include <config.h>
-#include <assert.h>
+#include "error.h"
 #include <stdlib.h>
 #include "alloc.h"
-#include "cases.h"
 #include "command.h"
+#include "dictionary.h"
 #include "error.h"
 #include "lexer.h"
 #include "misc.h"
@@ -44,8 +44,6 @@ cmd_vector (void)
   /* Maximum allocated position for vecnames, plus one position. */
   char *endp = NULL;
 
-  lex_match_id ("VECTOR");
-
   cp = vecnames = xmalloc (256);
   endp = &vecnames[256];
   do
@@ -115,7 +113,7 @@ cmd_vector (void)
          int ndig;
 
          /* Name of an individual variable to be created. */
-         char name[9];
+         char name[SHORT_NAME_LEN + 1];
 
           /* Vector variables. */
           struct variable **v;
@@ -133,13 +131,13 @@ cmd_vector (void)
          if (!lex_force_match (')'))
            goto fail;
 
-         /* First check that all the generated variable names are 8
+         /* First check that all the generated variable names are SHORT_NAME_LEN
             characters or shorter. */
          ndig = intlog10 (nv);
          for (cp = vecnames; *cp;)
            {
              int len = strlen (cp);
-             if (len + ndig > 8)
+             if (len + ndig > SHORT_NAME_LEN)
                {
                  msg (SE, _("%s%d is too long for a variable name."), cp, nv);
                  goto fail;
@@ -169,9 +167,7 @@ cmd_vector (void)
              for (i = 0; i < nv; i++)
                {
                  sprintf (name, "%s%d", cp, i + 1);
-                 v[i] = dict_create_var (default_dict, name, 0);
-                  assert (v[i] != NULL);
-                 envector (v[i]);
+                 v[i] = dict_create_var_assert (default_dict, name, 0);
                }
               if (!dict_create_vector (default_dict, cp, v, nv))
                 assert (0);