Adopt use of gnulib for portability.
[pspp-builds.git] / src / numeric.c
index 065b1a30294488df4d1b912c68c3398d75938914..a2b6d8047f748739a6ad1d23df118a45c8854e36 100644 (file)
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA. */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
 
 #include <config.h>
-#include <assert.h>
+#include "error.h"
 #include <stdlib.h>
-#include "cases.h"
 #include "command.h"
+#include "dictionary.h"
 #include "error.h"
 #include "lexer.h"
 #include "str.h"
 #include "var.h"
 
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
 #include "debug-print.h"
 
 /* Parses the NUMERIC command. */
@@ -43,7 +46,6 @@ cmd_numeric (void)
      be used. */
   struct fmt_spec f;
 
-  lex_match_id ("NUMERIC");
   do
     {
       if (!parse_DATA_LIST_vars (&v, &nv, PV_NONE))
@@ -73,15 +75,13 @@ cmd_numeric (void)
       /* Create each variable. */
       for (i = 0; i < nv; i++)
        {
-         struct variable *new_var = create_variable (&default_dict, v[i],
-                                              NUMERIC, 0);
+         struct variable *new_var = dict_create_var (default_dict, v[i], 0);
          if (!new_var)
            msg (SE, _("There is already a variable named %s."), v[i]);
          else
            {
              if (f.type != -1)
                new_var->print = new_var->write = f;
-             envector (new_var);
            }
        }
 
@@ -119,7 +119,6 @@ cmd_string (void)
   /* Width of variables to create. */
   int width;
 
-  lex_match_id ("STRING");
   do
     {
       if (!parse_DATA_LIST_vars (&v, &nv, PV_NONE))
@@ -151,20 +150,18 @@ cmd_string (void)
          break;
        default:
          assert (0);
+          abort ();
        }
 
       /* Create each variable. */
       for (i = 0; i < nv; i++)
        {
-         struct variable *new_var = create_variable (&default_dict, v[i],
-                                              ALPHA, width);
+         struct variable *new_var = dict_create_var (default_dict, v[i],
+                                                      width);
          if (!new_var)
            msg (SE, _("There is already a variable named %s."), v[i]);
          else
-           {
-             new_var->print = new_var->write = f;
-             envector (new_var);
-           }
+            new_var->print = new_var->write = f;
        }
 
       /* Clean up. */
@@ -194,16 +191,14 @@ cmd_leave (void)
 
   int i;
 
-  lex_match_id ("LEAVE");
-  if (!parse_variables (NULL, &v, &nv, PV_NONE))
+  if (!parse_variables (default_dict, &v, &nv, PV_NONE))
     return CMD_FAILURE;
   for (i = 0; i < nv; i++)
     {
-      if (v[i]->left)
+      if (!v[i]->reinit)
        continue;
-      devector (v[i]);
-      v[i]->left = 1;
-      envector (v[i]);
+      v[i]->reinit = 0;
+      v[i]->init = 1;
     }
   free (v);