table-item: Remove barely used parameters from table_item_create().
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 29 Dec 2020 07:35:45 +0000 (23:35 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 31 Dec 2020 03:58:11 +0000 (19:58 -0800)
The 'title' and 'caption' parameters were always NULL in practice, and
only one caller supplied nonnull 'notes'.

src/output/pivot-output.c
src/output/table-item.c
src/output/table-item.h
src/output/text-item.c
tests/output/render-test.c

index ae12c4dea391e51358a97de2ca85df32fa040c24..1488519ee270e46290dd9dd5588f0517bac1c4e8 100644 (file)
@@ -455,7 +455,10 @@ pivot_table_submit_layer (const struct pivot_table *pt,
   free (column_enumeration);
   free (row_enumeration);
 
-  struct table_item *ti = table_item_create (table, NULL, NULL, pt->notes);
+  struct table_item *ti = table_item_create (table);
+
+  if (pt->notes)
+    table_item_set_notes (ti, pt->notes);
 
   if (pt->title)
     {
index 1b17c320a6e8e5a119c5ac1ff70a79089dcd83c6..bc154d5462ab0f7b9072688dfc15bee91f178164 100644 (file)
@@ -122,20 +122,15 @@ table_item_layers_destroy (struct table_item_layers *layers)
     }
 }
 
-/* Initializes ITEM as a table item for rendering TABLE.  The new table item
-   initially has the specified TITLE, CAPTION, and NOTES, which may each be
-   NULL.  The caller retains ownership of TITLE, CAPTION, and NOTES. */
+/* Initializes ITEM as a table item for rendering TABLE.  Takes ownership of
+   TABLE. */
 struct table_item *
-table_item_create (struct table *table, const char *title, const char *caption,
-                   const char *notes)
+table_item_create (struct table *table)
 {
   struct table_item *item = xmalloc (sizeof *item);
   *item = (struct table_item) {
     .output_item = OUTPUT_ITEM_INITIALIZER (&table_item_class),
     .table = table,
-    .title = table_item_text_create (title),
-    .caption = table_item_text_create (caption),
-    .notes = notes ? xstrdup (notes) : NULL,
   };
   return item;
 }
index d1c30b668d603df5b4f2b0be3eaa1074669fc022..a4435a0f5971f6e5cf506dcd6aaf60f11c468ebe 100644 (file)
@@ -79,8 +79,7 @@ struct table_item
     struct pivot_table *pt;
   };
 
-struct table_item *table_item_create (struct table *, const char *title,
-                                      const char *caption, const char *notes);
+struct table_item *table_item_create (struct table *);
 
 const struct table *table_item_get_table (const struct table_item *);
 
index 55319e9ef676c68c3ff5dedfcc319879f9f2f1d3..2f0cef5ee7f6cbfb7cc8989a50b66ccf4b9bcfe4 100644 (file)
@@ -185,7 +185,7 @@ text_item_to_table_item (struct text_item *text_item)
   if (text_item->type == TEXT_ITEM_SYNTAX || text_item->type == TEXT_ITEM_LOG)
     opts |= TAB_FIX;
   table_text (tab, 0, 0, opts, text_item_get_text (text_item));
-  struct table_item *table_item = table_item_create (tab, NULL, NULL, NULL);
+  struct table_item *table_item = table_item_create (tab);
   text_item_unref (text_item);
   return table_item;
 }
index d9ca79603ac0e1ec864c616f7274dde6d810e88c..c382ee12c5ef307e51c03deca6fd3cc4f98f5e71 100644 (file)
@@ -114,7 +114,7 @@ main (int argc, char **argv)
         }
 
       table = tables[n_tables - 1];
-      table_item_submit (table_item_create (table, NULL, NULL, NULL));
+      table_item_submit (table_item_create (table));
       free (tables);
     }
   else