Yet more constness
[pspp-builds.git] / src / language / utilities / set.q
index b6b3963a715d702157b91edbfe424390be6e6d64..113373d73787b5fa6918c8f9cc5f77016f3faf73 100644 (file)
    02110-1301, USA. */
 
 #include <config.h>
-#include "settings.h"
-#include "message.h"
+
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
 #include <time.h>
-#include "alloc.h"
-#include "command.h"
-#include "dictionary.h"
-#include "line-buffer.h"
-#include "lexer.h"
-#include "message.h"
-#include "magic.h"
-#include "output.h"
-#include "random.h"
-#include "variable.h"
-#include "format.h"
-#include "copyleft.h"
-#include "variable.h"
 
+#include <data/dictionary.h>
+#include <data/format.h>
+#include <data/procedure.h>
+#include <data/settings.h>
+#include <data/variable.h>
+#include <language/command.h>
+#include <language/lexer/format-parser.h>
+#include <language/lexer/lexer.h>
+#include <language/line-buffer.h>
+#include <libpspp/alloc.h>
+#include <libpspp/compiler.h>
+#include <libpspp/copyleft.h>
+#include <libpspp/magic.h>
+#include <libpspp/message.h>
+#include <math/random.h>
+#include <output/output.h>
 
 #if HAVE_LIBTERMCAP
 #if HAVE_TERMCAP_H
@@ -109,6 +111,8 @@ int tgetnum (const char *);
      xsort=xsort:yes/no.
 */
 
+/* (headers) */
+
 /* (declarations) */
 
 /* (_functions) */
@@ -121,7 +125,7 @@ cmd_set (void)
   struct cmd_set cmd;
   bool ok = true;
 
-  if (!parse_set (&cmd))
+  if (!parse_set (&cmd, NULL))
     return CMD_FAILURE;
 
   if (cmd.sbc_cca)
@@ -168,29 +172,29 @@ cmd_set (void)
     set_workspace (cmd.n_workspace[0] * 1024L);
 
   if (cmd.sbc_block)
-    msg (SW, _("%s is obsolete."),"BLOCK");
+    msg (SW, _("%s is obsolete."), "BLOCK");
   if (cmd.sbc_boxstring)
-    msg (SW, _("%s is obsolete."),"BOXSTRING");
+    msg (SW, _("%s is obsolete."), "BOXSTRING");
   if (cmd.sbc_histogram)
-    msg (MW, _("%s is obsolete."),"HISTOGRAM");
-  if (cmd.sbc_menus )
-    msg (MW, _("%s is obsolete."),"MENUS");
-  if (cmd.sbc_xsort )
-    msg (SW, _("%s is obsolete."),"XSORT");
-  if (cmd.sbc_mxmemory )
-    msg (SE, _("%s is obsolete."),"MXMEMORY");
+    msg (SW, _("%s is obsolete."), "HISTOGRAM");
+  if (cmd.sbc_menus)
+    msg (SW, _("%s is obsolete."), "MENUS");
+  if (cmd.sbc_xsort)
+    msg (SW, _("%s is obsolete."), "XSORT");
+  if (cmd.sbc_mxmemory)
+    msg (SE, _("%s is obsolete."), "MXMEMORY");
   if (cmd.sbc_scripttab)
-    msg (SE, _("%s is obsolete."),"SCRIPTTAB");
+    msg (SE, _("%s is obsolete."), "SCRIPTTAB");
   if (cmd.sbc_tbfonts)
-    msg (SW, _("%s is obsolete."),"TBFONTS");
+    msg (SW, _("%s is obsolete."), "TBFONTS");
   if (cmd.sbc_tb1 && cmd.s_tb1)
-    msg (SW, _("%s is obsolete."),"TB1");
+    msg (SW, _("%s is obsolete."), "TB1");
 
   if (cmd.sbc_case)
     msg (SW, _("%s is not implemented."), "CASE");
 
   if (cmd.sbc_compression)
-    msg (MW, _("Active file compression is not implemented."));
+    msg (SW, _("Active file compression is not implemented."));
 
   return CMD_SUCCESS;
 }
@@ -285,7 +289,7 @@ do_cc (const char *cc_string, int idx)
    completely blank fields in numeric data imply.  X, Wnd: Syntax is
    SYSMIS or a numeric value. */
 static int
-stc_custom_blanks (struct cmd_set *cmd UNUSED)
+stc_custom_blanks (struct cmd_set *cmd UNUSED, void *aux UNUSED)
 {
   lex_match ('=');
   if ((token == T_ID && lex_id_match ("SYSMIS", tokid)))
@@ -306,7 +310,7 @@ stc_custom_blanks (struct cmd_set *cmd UNUSED)
 /* Parses the EPOCH subcommand, which controls the epoch used for
    parsing 2-digit years. */
 static int
-stc_custom_epoch (struct cmd_set *cmd UNUSED) 
+stc_custom_epoch (struct cmd_set *cmd UNUSED, void *aux UNUSED
 {
   lex_match ('=');
   if (lex_match_id ("AUTOMATIC"))
@@ -332,7 +336,7 @@ stc_custom_epoch (struct cmd_set *cmd UNUSED)
 }
 
 static int
-stc_custom_length (struct cmd_set *cmd UNUSED)
+stc_custom_length (struct cmd_set *cmd UNUSED, void *aux UNUSED)
 {
   int page_length;
 
@@ -359,7 +363,7 @@ stc_custom_length (struct cmd_set *cmd UNUSED)
 }
 
 static int
-stc_custom_seed (struct cmd_set *cmd UNUSED)
+stc_custom_seed (struct cmd_set *cmd UNUSED, void *aux UNUSED)
 {
   lex_match ('=');
   if (lex_match_id ("RANDOM"))
@@ -376,7 +380,7 @@ stc_custom_seed (struct cmd_set *cmd UNUSED)
 }
 
 static int
-stc_custom_width (struct cmd_set *cmd UNUSED)
+stc_custom_width (struct cmd_set *cmd UNUSED, void *aux UNUSED)
 {
   lex_match ('=');
   if (lex_match_id ("NARROW"))
@@ -402,12 +406,12 @@ stc_custom_width (struct cmd_set *cmd UNUSED)
 /* Parses FORMAT subcommand, which consists of a numeric format
    specifier. */
 static int
-stc_custom_format (struct cmd_set *cmd UNUSED)
+stc_custom_format (struct cmd_set *cmd UNUSED, void *aux UNUSED)
 {
   struct fmt_spec fmt;
 
   lex_match ('=');
-  if (!parse_format_specifier (&fmt, 0))
+  if (!parse_format_specifier (&fmt))
     return 0;
   if ((formats[fmt.type].cat & FCAT_STRING) != 0)
     {
@@ -422,7 +426,7 @@ stc_custom_format (struct cmd_set *cmd UNUSED)
 }
 
 static int
-stc_custom_journal (struct cmd_set *cmd UNUSED)
+stc_custom_journal (struct cmd_set *cmd UNUSED, void *aux UNUSED)
 {
   lex_match ('=');
   if (!lex_match_id ("ON") && !lex_match_id ("OFF")) 
@@ -439,7 +443,7 @@ stc_custom_journal (struct cmd_set *cmd UNUSED)
 }
 
 static int
-stc_custom_listing (struct cmd_set *cmd UNUSED)
+stc_custom_listing (struct cmd_set *cmd UNUSED, void *aux UNUSED)
 {
   bool listing;
 
@@ -459,18 +463,18 @@ stc_custom_listing (struct cmd_set *cmd UNUSED)
 }
 
 static int
-stc_custom_disk (struct cmd_set *cmd UNUSED)
+stc_custom_disk (struct cmd_set *cmd UNUSED, void *aux)
 {
-  return stc_custom_listing (cmd);
+  return stc_custom_listing (cmd, aux);
 }
 \f
 static void
 show_blanks (void) 
 {
   if (get_blanks () == SYSMIS)
-    msg (MM, _("BLANKS is SYSMIS."));
+    msg (SN, _("BLANKS is SYSMIS."));
   else
-    msg (MM, _("BLANKS is %g."), get_blanks ());
+    msg (SN, _("BLANKS is %g."), get_blanks ());
 
 }
 
@@ -502,7 +506,7 @@ show_cc (int idx)
   out = format_cc (cc->neg_suffix, cc->grouping, out);
   *out = '\0';
   
-  msg (MM, _("CC%c is \"%s\"."), "ABCDE"[idx], cc_string);
+  msg (SN, _("CC%c is \"%s\"."), "ABCDE"[idx], cc_string);
 }
 
 
@@ -539,77 +543,77 @@ show_cce (void)
 static void
 show_decimals (void) 
 {
-  msg (MM, _("DECIMAL is \"%c\"."), get_decimal ());
+  msg (SN, _("DECIMAL is \"%c\"."), get_decimal ());
 }
 
 static void
 show_endcmd (void) 
 {
-  msg (MM, _("ENDCMD is \"%c\"."), get_endcmd ());
+  msg (SN, _("ENDCMD is \"%c\"."), get_endcmd ());
 }
 
 static void
 show_format (void) 
 {
-  msg (MM, _("FORMAT is %s."), fmt_to_string (get_format ()));
+  msg (SN, _("FORMAT is %s."), fmt_to_string (get_format ()));
 }
 
 static void
 show_length (void) 
 {
-  msg (MM, _("LENGTH is %d."), get_viewlength ());
+  msg (SN, _("LENGTH is %d."), get_viewlength ());
 }
 
 static void
 show_mxerrs (void) 
 {
-  msg (MM, _("MXERRS is %d."), get_mxerrs ());
+  msg (SN, _("MXERRS is %d."), get_mxerrs ());
 }
 
 static void
 show_mxloops (void) 
 {
-  msg (MM, _("MXLOOPS is %d."), get_mxloops ());
+  msg (SN, _("MXLOOPS is %d."), get_mxloops ());
 }
 
 static void
 show_mxwarns (void) 
 {
-  msg (MM, _("MXWARNS is %d."), get_mxwarns ());
+  msg (SN, _("MXWARNS is %d."), get_mxwarns ());
 }
 
 static void
 show_scompression (void) 
 {
   if (get_scompression ())
-    msg (MM, _("SCOMPRESSION is ON."));
+    msg (SN, _("SCOMPRESSION is ON."));
   else
-    msg (MM, _("SCOMPRESSION is OFF."));
+    msg (SN, _("SCOMPRESSION is OFF."));
 }
 
 static void
 show_undefined (void) 
 {
   if (get_undefined ())
-    msg (MM, _("UNDEFINED is WARN."));
+    msg (SN, _("UNDEFINED is WARN."));
   else
-    msg (MM, _("UNDEFINED is NOWARN."));
+    msg (SN, _("UNDEFINED is NOWARN."));
 }
 
 static void
 show_weight (void) 
 {
-  struct variable *var = dict_get_weight (default_dict);
+  struct variable *var = dict_get_weight (dataset_dict (current_dataset));
   if (var == NULL)
-    msg (MM, _("WEIGHT is off."));
+    msg (SN, _("WEIGHT is off."));
   else
-    msg (MM, _("WEIGHT is variable %s."), var->name);
+    msg (SN, _("WEIGHT is variable %s."), var->name);
 }
 
 static void
 show_width (void) 
 {
-  msg (MM, _("WIDTH is %d."), get_viewwidth ());
+  msg (SN, _("WIDTH is %d."), get_viewwidth ());
 }
 
 struct show_sbc 
@@ -618,7 +622,7 @@ struct show_sbc
     void (*function) (void);
   };
 
-struct show_sbc show_table[] = 
+const struct show_sbc show_table[] = 
   {
     {"BLANKS", show_blanks},
     {"CCA", show_cca},
@@ -660,13 +664,13 @@ show_all_cc (void)
 static void
 show_warranty (void) 
 {
-  msg (MM, lack_of_warranty);
+  msg (MN, lack_of_warranty);
 }
 
 static void
 show_copying (void) 
 {
-  msg (MM, copyleft);
+  msg (MN, copyleft);
 }
 
 int
@@ -699,14 +703,14 @@ cmd_show (void)
                 goto found;
               }
           lex_error (NULL);
-          return CMD_PART_SUCCESS_MAYBE;
+          return CMD_FAILURE;
 
         found: ;
         }
       else 
         {
           lex_error (NULL);
-          return CMD_PART_SUCCESS_MAYBE;
+          return CMD_FAILURE;
         }
 
       lex_match ('/');