output: Introduce pivot tables.
[pspp] / src / language / utilities / set.q
index f90e3e14de3d8e675b7988879a79c3a2cca83b67..8b06448fe474fd9f2540d7036fe5aabb5e8d556f 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -80,6 +80,7 @@ int tgetnum (const char *);
      epoch=custom;
      errors=custom;
      format=custom;
+     fuzzbits=integer;
      headers=headers:no/yes/blank;
      highres=hires:on/off;
      histogram=string;
@@ -136,7 +137,6 @@ cmd_set (struct lexer *lexer, struct dataset *ds)
 
   if (!parse_set (lexer, ds, &cmd, NULL))
     {
-      free_set (&cmd);
       return CMD_FAILURE;
     }
 
@@ -153,6 +153,14 @@ cmd_set (struct lexer *lexer, struct dataset *ds)
 
   if (cmd.sbc_decimal)
     settings_set_decimal_char (cmd.dec == STC_DOT ? '.' : ',');
+  if (cmd.sbc_fuzzbits)
+    {
+      int fuzzbits = cmd.n_fuzzbits[0];
+      if (fuzzbits >= 0 && fuzzbits <= 20)
+        settings_set_fuzzbits (fuzzbits);
+      else
+        msg (SE, _("%s must be between 0 and 20."), "FUZZBITS");
+    }
 
   if (cmd.sbc_include)
     settings_set_include (cmd.inc == STC_ON);
@@ -338,17 +346,11 @@ 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);
@@ -367,17 +369,11 @@ 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);
@@ -559,7 +555,7 @@ stc_custom_format (struct lexer *lexer, struct dataset *ds UNUSED, struct cmd_se
 
   if (!fmt_check_output (&fmt))
     return 0;
-  
+
   if (fmt_is_string (fmt.type))
     {
       char str[FMT_STRING_LEN_MAX + 1];
@@ -710,6 +706,12 @@ show_format (const struct dataset *ds UNUSED)
   return xstrdup (fmt_to_string (settings_get_format (), str));
 }
 
+static char *
+show_fuzzbits (const struct dataset *ds UNUSED)
+{
+  return xasprintf ("%d", settings_get_fuzzbits ());
+}
+
 static char *
 show_journal (const struct dataset *ds UNUSED)
 {
@@ -892,7 +894,7 @@ show_current_directory (const struct dataset *ds UNUSED)
     {
       len <<= 1;
       buf = xrealloc (buf, len);
-    } 
+    }
   while (NULL == (wd = getcwd (buf, len)));
 
   return wd;
@@ -907,7 +909,7 @@ show_tempdir (const struct dataset *ds UNUSED)
 static char *
 show_version (const struct dataset *ds UNUSED)
 {
-  return strdup (version);
+  return strdup (announced_version);
 }
 
 static char *
@@ -952,6 +954,7 @@ const struct show_sbc show_table[] =
     {"ENVIRONMENT", show_system},
     {"ERRORS", show_errors},
     {"FORMAT", show_format},
+    {"FUZZBITS", show_fuzzbits},
     {"JOURNAL", show_journal},
     {"LENGTH", show_length},
     {"LOCALE", show_locale},