Work on docs
[pspp] / src / output / tex.c
index 254d6a686183e64b9ebc60b76e301eb1995bc371..7a09c5eae60df1e7d3c6605d6cf430e2a2044674 100644 (file)
@@ -175,7 +175,11 @@ post_process_tokens (FILE *file, struct ll_list *list)
               if (nt->cat == CAT_SPACE || nt->cat == CAT_EOL)
                 break;
               if (prev_x && (prev_x->cat == CAT_COMMENT) && (nt->cat != CAT_COMMENT))
-                break;
+                {
+                  ds_destroy (&prev_x->str);
+                  free (prev_x);
+                  break;
+                }
               word_len += ds_length (&nt->str);
               prev_x = nt;
             }
@@ -184,6 +188,11 @@ post_process_tokens (FILE *file, struct ll_list *list)
             {
               fputs ("\n", file);
               line_len = 0;
+              if (tt)
+                {
+                  ds_destroy (&tt->str);
+                  free (tt);
+                }
               continue;
             }
         }
@@ -329,7 +338,7 @@ tex_submit (struct output_driver *driver, const struct output_item *item)
       break;
 
     case OUTPUT_ITEM_GROUP:
-      NOT_REACHED ();
+      break;
 
     case OUTPUT_ITEM_IMAGE:
       {
@@ -356,9 +365,6 @@ tex_submit (struct output_driver *driver, const struct output_item *item)
     case OUTPUT_ITEM_PAGE_BREAK:
       break;
 
-    case OUTPUT_ITEM_PAGE_SETUP:
-      break;
-
     case OUTPUT_ITEM_TABLE:
       tex_output_table (tex, item->table);
       break;
@@ -396,13 +402,12 @@ tex_submit (struct output_driver *driver, const struct output_item *item)
 static void
 tex_put_footnote_markers (struct tex_driver *tex,
                           const struct pivot_table *pt,
-                          const size_t *footnote_indexes,
-                          size_t n_footnotes)
+                          const struct pivot_value_ex *ex)
 {
   size_t n_visible = 0;
-  for (size_t i = 0; i < n_footnotes; i++)
+  for (size_t i = 0; i < ex->n_footnotes; i++)
     {
-      const struct pivot_footnote *f = pt->footnotes[footnote_indexes[i]];
+      const struct pivot_footnote *f = pt->footnotes[ex->footnote_indexes[i]];
       if (f->show)
         {
           if (!n_visible++)
@@ -426,9 +431,7 @@ tex_put_table_cell (struct tex_driver *tex, const struct pivot_table *pt,
   tex_escape_string (tex, ds_cstr (&s), false);
   ds_destroy (&s);
 
-  tex_put_footnote_markers (tex, pt,
-                            cell->value->footnote_indexes,
-                            cell->value->n_footnotes);
+  tex_put_footnote_markers (tex, pt, pivot_value_ex (cell->value));
 }
 
 static void
@@ -552,8 +555,7 @@ tex_output_table_layer (struct tex_driver *tex, const struct pivot_table *pt,
           tex_escape_string (tex, ds_cstr (&s), true);
           ds_destroy (&s);
 
-          tex_put_footnote_markers (tex, pt, cell.value->footnote_indexes,
-                                    cell.value->n_footnotes);
+          tex_put_footnote_markers (tex, pt, pivot_value_ex (cell.value));
           if (halign == TABLE_HALIGN_CENTER || halign == TABLE_HALIGN_RIGHT)
             {
               shipout (&tex->token_list, "}");