pivot-table: Fix memory leak in pivot_table_destroy()
[pspp] / src / output / csv.c
index 1c6662793fc3fafd5c40f83d3a668f700e32bc8d..e5b47a06ef0b7c0e1c35517d96338062073c0975 100644 (file)
@@ -30,6 +30,7 @@
 #include "output/driver-provider.h"
 #include "output/options.h"
 #include "output/message-item.h"
+#include "output/page-eject-item.h"
 #include "output/table-item.h"
 #include "output/table-provider.h"
 
@@ -214,9 +215,9 @@ csv_submit (struct output_driver *driver,
         csv_output_table_item_text (csv, table_item_get_title (table_item),
                                     "Table");
 
-      for (y = 0; y < table_nr (t); y++)
+      for (y = 0; y < t->n[TABLE_VERT]; y++)
         {
-          for (x = 0; x < table_nc (t); x++)
+          for (x = 0; x < t->n[TABLE_HORZ]; x++)
             {
               struct table_cell cell;
 
@@ -228,7 +229,7 @@ csv_submit (struct output_driver *driver,
               if (x != cell.d[TABLE_HORZ][0] || y != cell.d[TABLE_VERT][0])
                 csv_output_field (csv, "");
               else if (!(cell.options & TAB_MARKUP) && !cell.n_footnotes
-                       && !cell.n_subscripts && !cell.superscript)
+                       && !cell.n_subscripts)
                 csv_output_field (csv, cell.text);
               else
                 {
@@ -247,8 +248,6 @@ csv_submit (struct output_driver *driver,
                     for (size_t i = 0; i < cell.n_subscripts; i++)
                       ds_put_format (&s, "%c%s",
                                      i ? ',' : '_', cell.subscripts[i]);
-                  if (cell.superscript)
-                    ds_put_format (&s, "^%s", cell.superscript);
                   csv_format_footnotes (cell.footnotes, cell.n_footnotes, &s);
                   csv_output_field (csv, ds_cstr (&s));
                   ds_destroy (&s);
@@ -298,6 +297,11 @@ csv_submit (struct output_driver *driver,
       else
         csv_output_lines (csv, text);
     }
+  else if (is_page_eject_item (output_item))
+    {
+      csv_put_separator (csv);
+      csv_output_lines (csv, "");
+    }
   else if (is_message_item (output_item))
     {
       const struct message_item *message_item = to_message_item (output_item);