Separate table functions that format their arguments from those that don't.
[pspp-builds.git] / src / language / stats / crosstabs.q
index 907868c0c264c242af4b780cffebe40086314610..a6b224693737a2e85212687c053c066190684c49 100644 (file)
@@ -161,41 +161,6 @@ struct pivot_table
     double total;              /* Grand total. */
   };
 
-/* A crosstabulation of exactly 2 variables, conditional on zero
-   or more other variables having given values. */
-struct crosstab
-  {
-    /* Case counts. */
-    double missing;
-
-    /* Variables. */
-    int n_vars;                        /* Number of variables (at least 2). */
-    const struct variable **vars;
-    union value *values;       /* Values of variables beyond 2. */
-
-    /* Data. */
-    struct table_entry **entries;
-    size_t n_entries;
-
-    /* Column values, number of columns. */
-    union value *cols;
-    int n_cols;
-
-    /* Row values, number of rows. */
-    union value *rows;
-    int n_rows;
-
-    /* Number of statistically interesting columns/rows
-       (columns/rows with data in them). */
-    int ns_cols, ns_rows;
-
-    /* Matrix contents. */
-    double *mat;               /* Matrix proper. */
-    double *row_tot;           /* Row totals. */
-    double *col_tot;           /* Column totals. */
-    double total;              /* Grand total. */
-  };
-
 /* Integer mode variable info. */
 struct var_range
   {
@@ -916,8 +881,8 @@ make_summary_table (struct crosstabs_proc *proc)
         {
           tab_double (summary, i * 2 + 1, 0, TAB_RIGHT, n[i],
                       &proc->weight_format);
-          tab_text (summary, i * 2 + 2, 0, TAB_RIGHT | TAT_PRINTF, "%.1f%%",
-                    n[i] / n[2] * 100.);
+          tab_text_format (summary, i * 2 + 2, 0, TAB_RIGHT, "%.1f%%",
+                           n[i] / n[2] * 100.);
         }
 
       tab_next_row (summary);
@@ -1028,22 +993,22 @@ output_pivot_table (struct crosstabs_proc *proc, struct pivot_table *pt)
       if (chisq)
         {
           display_dimensions (proc, &x, chisq, first_difference);
-          display_chisq (pt, chisq, &showed_fisher);
+          display_chisq (&x, chisq, &showed_fisher);
         }
       if (sym)
         {
           display_dimensions (proc, &x, sym, first_difference);
-          display_symmetric (proc, pt, sym);
+          display_symmetric (proc, &x, sym);
         }
       if (risk)
         {
           display_dimensions (proc, &x, risk, first_difference);
-          display_risk (pt, risk);
+          display_risk (&x, risk);
         }
       if (direct)
         {
           display_dimensions (proc, &x, direct, first_difference);
-          display_directional (proc, pt, direct);
+          display_directional (proc, &x, direct);
         }
 
       /* Free the parts of x that are not owned by pt.  In
@@ -1271,7 +1236,6 @@ create_chisq_table (struct pivot_table *pt)
             _("Exact. Sig. (2-sided)"));
   tab_text (chisq, 5, 0, TAB_RIGHT | TAT_TITLE,
             _("Exact. Sig. (1-sided)"));
-  chisq = 0;
   tab_offset (chisq, 0, 1);
 
   return chisq;
@@ -1312,8 +1276,8 @@ create_risk_table (struct pivot_table *pt)
   tab_title (risk, _("Risk estimate."));
 
   tab_offset (risk, pt->n_vars - 2, 0);
-  tab_joint_text (risk, 2, 0, 3, 0, TAB_CENTER | TAT_TITLE | TAT_PRINTF,
-                  _("95%% Confidence Interval"));
+  tab_joint_text_format (risk, 2, 0, 3, 0, TAB_CENTER | TAT_TITLE,
+                         _("95%% Confidence Interval"));
   tab_text (risk, 0, 1, TAB_LEFT | TAT_TITLE, _("Statistic"));
   tab_text (risk, 1, 1, TAB_RIGHT | TAT_TITLE, _("Value"));
   tab_text (risk, 2, 1, TAB_RIGHT | TAT_TITLE, _("Lower"));
@@ -1816,7 +1780,6 @@ display_chisq (struct pivot_table *pt, struct tab_table *chisq,
   double chisq_v[N_CHISQ];
   double fisher1, fisher2;
   int df[N_CHISQ];
-  int s = 0;
 
   int i;
 
@@ -1829,7 +1792,6 @@ display_chisq (struct pivot_table *pt, struct tab_table *chisq,
       if ((i != 2 && chisq_v[i] == SYSMIS)
          || (i == 2 && fisher1 == SYSMIS))
        continue;
-      s = 1;
 
       tab_text (chisq, 0, 0, TAB_LEFT, gettext (chisq_stats[i]));
       if (i != 2)
@@ -2098,8 +2060,8 @@ display_directional (struct crosstabs_proc *proc, struct pivot_table *pt,
                  else
                    string = var_get_name (pt->vars[1]);
 
-                 tab_text (direct, j, 0, TAB_LEFT | TAT_PRINTF,
-                           gettext (stats_names[j][k]), string);
+                 tab_text_format (direct, j, 0, TAB_LEFT,
+                                   gettext (stats_names[j][k]), string);
                }
            }
       }