Add --table-look command line option and SET TLOOK command.
[pspp] / src / language / utilities / set.q
index 710bc2f44e44d5372e960bc7a1433109427dd1e4..ddc7fc629da3b671a85b25f435999371aee0647c 100644 (file)
@@ -48,6 +48,7 @@
 #include "math/random.h"
 #include "output/driver.h"
 #include "output/journal.h"
+#include "output/pivot-table.h"
 
 #if HAVE_LIBTERMCAP
 #if HAVE_TERMCAP_H
@@ -113,6 +114,7 @@ int tgetnum (const char *);
      tvars=custom;
      tb1=string;
      tbfonts=string;
+     tlook=custom;
      undefined=undef:warn/nowarn;
      wib=wib:msbfirst/lsbfirst/vax/native;
      wrb=wrb:native/isl/isb/idl/idb/vf/vd/vg/zs/zl;
@@ -346,20 +348,14 @@ stc_custom_tnumbers (struct lexer *lexer,
   lex_match (lexer, T_EQUALS);
 
   if (lex_match_id (lexer, "VALUES"))
-    {
-      settings_set_value_style (SETTINGS_VAL_STYLE_VALUES);
-    }
+    settings_set_show_values (SETTINGS_VALUE_SHOW_VALUE);
   else if (lex_match_id (lexer, "LABELS"))
-    {
-      settings_set_value_style (SETTINGS_VAL_STYLE_LABELS);
-    }
+    settings_set_show_values (SETTINGS_VALUE_SHOW_LABEL);
   else if (lex_match_id (lexer, "BOTH"))
-    {
-      settings_set_value_style (SETTINGS_VAL_STYLE_BOTH);
-    }
+    settings_set_show_values (SETTINGS_VALUE_SHOW_BOTH);
   else
     {
-      lex_error_expecting (lexer, "VALUES", "LABELS", "BOTH", NULL_SENTINEL);
+      lex_error_expecting (lexer, "VALUES", "LABELS", "BOTH");
       return 0;
     }
 
@@ -375,26 +371,48 @@ stc_custom_tvars (struct lexer *lexer,
   lex_match (lexer, T_EQUALS);
 
   if (lex_match_id (lexer, "NAMES"))
-    {
-      settings_set_var_style (SETTINGS_VAR_STYLE_NAMES);
-    }
+    settings_set_show_variables (SETTINGS_VALUE_SHOW_VALUE);
   else if (lex_match_id (lexer, "LABELS"))
-    {
-      settings_set_var_style (SETTINGS_VAR_STYLE_LABELS);
-    }
+    settings_set_show_variables (SETTINGS_VALUE_SHOW_LABEL);
   else if (lex_match_id (lexer, "BOTH"))
-    {
-      settings_set_var_style (SETTINGS_VAR_STYLE_BOTH);
-    }
+    settings_set_show_variables (SETTINGS_VALUE_SHOW_BOTH);
   else
     {
-      lex_error_expecting (lexer, "NAMES", "LABELS", "BOTH", NULL_SENTINEL);
+      lex_error_expecting (lexer, "NAMES", "LABELS", "BOTH");
       return 0;
     }
 
   return 1;
 }
 
+static int
+stc_custom_tlook (struct lexer *lexer,
+                  struct dataset *ds UNUSED,
+                  struct cmd_set *cmd UNUSED, void *aux UNUSED)
+{
+  lex_match (lexer, T_EQUALS);
+
+  if (lex_match_id (lexer, "NONE"))
+    pivot_table_look_set_default (pivot_table_look_builtin_default ());
+  else if (lex_is_string (lexer))
+    {
+      struct pivot_table_look *look;
+      char *error = pivot_table_look_read (lex_tokcstr (lexer), &look);
+      lex_get (lexer);
+
+      if (error)
+        {
+          msg (SE, "%s", error);
+          free (error);
+          return 0;
+        }
+
+      pivot_table_look_set_default (look);
+      pivot_table_look_unref (look);
+    }
+
+  return 1;
+}
 
 /* Parses the EPOCH subcommand, which controls the epoch used for
    parsing 2-digit years. */