Rewrite expression code.
[pspp-builds.git] / src / formats.c
index 8d2918a769a2528da8d0673f4619ba09e274d256..9ad6efc31bb94db3ed186cb8e14164a566547682 100644 (file)
 #include "str.h"
 #include "var.h"
 
-#undef DEBUGGING
-/*#define DEBUGGING 1*/
 #include "debug-print.h"
 
-#if DEBUGGING
-static void debug_print (void);
-#endif
-
 enum
   {
     FORMATS_PRINT = 001,
@@ -47,21 +41,18 @@ static int internal_cmd_formats (int);
 int
 cmd_print_formats (void)
 {
-  lex_match_id ("FORMATS");
   return internal_cmd_formats (FORMATS_PRINT);
 }
 
 int
 cmd_write_formats (void)
 {
-  lex_match_id ("FORMATS");
   return internal_cmd_formats (FORMATS_WRITE);
 }
 
 int
 cmd_formats (void)
 {
-  lex_match_id ("FORMATS");
   return internal_cmd_formats (FORMATS_PRINT | FORMATS_WRITE);
 }
 
@@ -86,7 +77,7 @@ internal_cmd_formats (int which)
       if (token == '.')
        break;
 
-      if (!parse_variables (NULL, &v, &cv, PV_SAME_TYPE))
+      if (!parse_variables (default_dict, &v, &cv, PV_SAME_TYPE))
        return CMD_PART_SUCCESS_MAYBE;
       type = v[0]->type;
 
@@ -95,7 +86,7 @@ internal_cmd_formats (int which)
          msg (SE, _("`(' expected after variable list"));
          goto fail;
        }
-      if (!parse_format_specifier (&f, 0) || !check_output_specifier (&f))
+      if (!parse_format_specifier (&f, 0) || !check_output_specifier (&f, 1))
        goto fail;
 
       /* Catch type mismatch errors. */
@@ -136,30 +127,9 @@ internal_cmd_formats (int which)
       free (v);
       v = NULL;
     }
-#if DEBUGGING
-  debug_print ();
-#endif
   return CMD_SUCCESS;
 
 fail:
   free (v);
   return CMD_PART_SUCCESS_MAYBE;
 }
-
-#if DEBUGGING
-static void
-debug_print (void)
-{
-  int i;
-
-  printf (_("Formats:\n"));
-  printf (_("  Name      Print         Write\n"));
-  printf ("  --------  ------------  ------------\n");
-  for (i = 0; i < default_dict.nvar; i++)
-    {
-      struct variable *v = default_dict.var[i];
-      printf ("  %-8s  %-12s", v->name, fmt_to_string (&v->print));
-      printf ("  %-12s\n", fmt_to_string (&v->write));
-    }
-}
-#endif /* DEBUGGING */