DO REPEAT: Order PRINT output correctly.
[pspp] / src / output / pivot-table.c
index 661813f28b22d0522a8fdbe5465bdf71796f95b3..9251621676f2dd630ebde735ba955fba3b0b7f56 100644 (file)
@@ -776,7 +776,7 @@ pivot_table_use_rc (const struct pivot_table *table, const char *s,
     {
       if (!strcmp (s, PIVOT_RC_OTHER))
         {
-          *format = *settings_get_format ();
+          *format = settings_get_format ();
           *honor_small = true;
         }
       else if (!strcmp (s, PIVOT_RC_COUNT) && !overridden_count_format)
@@ -804,13 +804,13 @@ pivot_table_use_rc (const struct pivot_table *table, const char *s,
    include the RC_ prefix) to *FORMAT.  Returns true if successful, false if S
    does not name a known result class. */
 bool
-pivot_result_class_change (const char *s_, const struct fmt_spec *format)
+pivot_result_class_change (const char *s_, struct fmt_spec format)
 {
   char *s = xasprintf ("RC_%s", s_);
   struct result_class *rc = pivot_result_class_find (s);
   if (rc)
     {
-      rc->format = *format;
+      rc->format = format;
       if (!strcmp (s, PIVOT_RC_COUNT))
         overridden_count_format = true;
     }
@@ -1372,15 +1372,13 @@ pivot_table_set_weight_var (struct pivot_table *table,
 }
 
 /* Sets the format used for PIVOT_RC_COUNT cells to WFMT, which should be the
-   format for the dictionary whose data or statistics are being put into TABLE.
-
-   This has no effect if WFMT is NULL. */
+   format for the dictionary whose data or statistics are being put into
+   TABLE. */
 void
-pivot_table_set_weight_format (struct pivot_table *table,
-                               const struct fmt_spec *wfmt)
+pivot_table_set_weight_format (struct pivot_table *table, struct fmt_spec wfmt)
 {
-  if (wfmt)
-    table->weight_format = *wfmt;
+  wfmt.w = 40;
+  table->weight_format = wfmt;
 }
 
 /* Returns true if TABLE has no cells, false otherwise. */
@@ -1474,7 +1472,7 @@ pivot_table_put (struct pivot_table *table, const size_t *dindexes, size_t n,
                 }
             }
         }
-      value->numeric.format = *settings_get_format ();
+      value->numeric.format = settings_get_format ();
       value->numeric.honor_small = true;
 
     done:;
@@ -2411,13 +2409,13 @@ pivot_value_format_body (const struct pivot_value *value,
                              value->numeric.value_label != NULL);
       if (show & SETTINGS_VALUE_SHOW_VALUE)
         {
-          const struct fmt_spec *f = &value->numeric.format;
-          const struct fmt_spec *format
-            = (f->type == FMT_F
+          struct fmt_spec f = value->numeric.format;
+          const struct fmt_spec format
+            = (f.type == FMT_F
                && value->numeric.honor_small
                && value->numeric.x != 0
                && fabs (value->numeric.x) < pt->small
-               ? &(struct fmt_spec) { .type = FMT_E, .w = 40, .d = f->d }
+               ? (struct fmt_spec) { .type = FMT_E, .w = 40, .d = f.d }
                : f);
 
           char *s = data_out (&(union value) { .f = value->numeric.x },
@@ -2872,7 +2870,7 @@ pivot_value_new_var_value (const struct variable *variable,
    encoding. */
 struct pivot_value *
 pivot_value_new_value (const union value *value, int width,
-                       const struct fmt_spec *format, const char *encoding)
+                       struct fmt_spec format, const char *encoding)
 {
   struct pivot_value *pv = XZALLOC (struct pivot_value);
   if (width > 0)
@@ -2885,13 +2883,13 @@ pivot_value_new_value (const union value *value, int width,
 
       pv->type = PIVOT_VALUE_STRING;
       pv->string.s = s;
-      pv->string.hex = format->type == FMT_AHEX;
+      pv->string.hex = format.type == FMT_AHEX;
     }
   else
     {
       pv->type = PIVOT_VALUE_NUMERIC;
       pv->numeric.x = value->f;
-      pv->numeric.format = *format;
+      pv->numeric.format = format;
     }
 
   return pv;
@@ -2915,7 +2913,7 @@ pivot_value_new_variable__ (const char *name, const char *label)
     .variable = {
       .type = PIVOT_VALUE_VARIABLE,
       .var_name = xstrdup (name),
-      .var_label = xstrdup_if_nonempty (label),
+      .var_label = xstrdup_if_nonnull (label),
     },
   };
   return value;