Add support for reading and writing SPV files.
[pspp] / src / output / table.c
index 18b822ba70c5c7c4405e3f28f54c7d2c752e3daa..09d45af7c5721107e8b6221febfa812439617de2 100644 (file)
@@ -289,13 +289,27 @@ table_collect_footnotes (const struct table_item *item,
     footnotes = add_footnotes (title->footnotes, title->n_footnotes,
                                footnotes, &allocated, &n);
 
+  const struct table_item_layers *layers = table_item_get_layers (item);
+  if (layers)
+    {
+      for (size_t i = 0; i < layers->n_layers; i++)
+        footnotes = add_footnotes (layers->layers[i].footnotes,
+                                   layers->layers[i].n_footnotes,
+                                   footnotes, &allocated, &n);
+    }
+
   const struct table_item_text *caption = table_item_get_caption (item);
   if (caption)
     footnotes = add_footnotes (caption->footnotes, caption->n_footnotes,
                                footnotes, &allocated, &n);
 
+  size_t n_nonnull = 0;
+  for (size_t i = 0; i < n; i++)
+    if (footnotes[i])
+      footnotes[n_nonnull++] = footnotes[i];
+
   *footnotesp = footnotes;
-  return n;
+  return n_nonnull;
 }
 \f
 const char *