Revert "work on crash"
authorBen Pfaff <blp@cs.stanford.edu>
Wed, 10 Aug 2022 05:39:18 +0000 (22:39 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Wed, 10 Aug 2022 05:39:18 +0000 (22:39 -0700)
This reverts commit 7cd70df07f7e183645853716642810afd4b87bcd.

src/language/stats/ctables.c
tests/language/stats/ctables.at

index 2833ce6b519911419408066728faa81cf50c375f..da511b69510f16bc7fb9d303392f7d719a1f4c55 100644 (file)
@@ -4362,8 +4362,6 @@ ctables_format (double d, const struct fmt_spec *format,
 static void
 ctables_table_output (struct ctables *ct, struct ctables_table *t)
 {
-  printf ("\n");
-
   struct pivot_table *pt = pivot_table_create__ (
     (t->title
      ? pivot_value_new_user_text (t->title, SIZE_MAX)
@@ -4381,7 +4379,6 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t)
                                 && t->summary_specs.n > 1));
   if (summary_dimension)
     {
-      printf ("summary_dimension\n");
       struct pivot_dimension *d = pivot_dimension_create (
         pt, t->slabels_axis, N_("Statistics"));
       const struct ctables_summary_spec_set *specs = &t->summary_specs;
@@ -4395,7 +4392,6 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t)
   bool categories_dimension = t->clabels_example != NULL;
   if (categories_dimension)
     {
-      printf ("categories_dimension\n");
       struct pivot_dimension *d = pivot_dimension_create (
         pt, t->label_axis[t->clabels_from_axis],
         t->clabels_from_axis == PIVOT_AXIS_ROW
@@ -4418,9 +4414,17 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t)
   struct pivot_dimension *d[PIVOT_N_AXES];
   for (enum pivot_axis_type a = 0; a < PIVOT_N_AXES; a++)
     {
-      d[a] = NULL;
-      if (!t->axes[a] && a != t->summary_axis)
+      static const char *names[] = {
+        [PIVOT_AXIS_ROW] = N_("Rows"),
+        [PIVOT_AXIS_COLUMN] = N_("Columns"),
+        [PIVOT_AXIS_LAYER] = N_("Layers"),
+      };
+      d[a] = (t->axes[a] || a == t->summary_axis
+              ? pivot_dimension_create (pt, a, names[a])
+              : NULL);
+      if (!d[a])
         continue;
+
       assert (t->axes[a]);
 
       for (size_t i = 0; i < t->stacks[a].n; i++)
@@ -4532,17 +4536,6 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t)
               };
             }
 
-          if (!n_levels)
-            goto next_free;
-
-          static const char *names[] = {
-            [PIVOT_AXIS_ROW] = N_("Rows"),
-            [PIVOT_AXIS_COLUMN] = N_("Columns"),
-            [PIVOT_AXIS_LAYER] = N_("Layers"),
-          };
-          d[a] = pivot_dimension_create (pt, a, names[a]);
-          printf ("%s dimension\n", names[a]);
-
           /* Pivot categories:
 
              - variable label for nest->vars[0], if vlabel != CTVL_NONE
@@ -4640,9 +4633,8 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t)
 
               cell->axes[a].leaf = prev_leaf;
             }
-          free (groups);
-        next_free:
           free (sorted);
+          free (groups);
           free (levels);
           free (sections);
         }
index a60ec46b227109aad0d201a4465412f06dc63531..726da3d723c4e3fc50060a329306ead40e143f6c 100644 (file)
@@ -2964,15 +2964,6 @@ AT_SETUP([CTABLES scale summary functions - assertion failure])
 AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .])
 AT_DATA([ctables.sps],
 [[GET 'nhtsa.sav'.
-CTABLES
-    /VLABELS VARIABLE=qn19a DISPLAY=BOTH
-    /TABLE region BY qn19a
-    /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE
-    /SLABELS POSITION=ROW.
-CTABLES
-    /VLABELS VARIABLE=qn19a DISPLAY=NONE
-    /TABLE region BY qn19a
-    /CATEGORIES VARIABLES=qn19a TOTAL=YES MISSING=INCLUDE.
 CTABLES
     /VLABELS VARIABLE=qn19a DISPLAY=NONE
     /TABLE region BY qn19a