Avoid "definition without prototype" warnings
[pspp] / src / output / render.c
index f41f504df0a90cc4e73a5941d3c238fb8ecbe17e..c50e1121e76d573a9e72132ce9dc2dd97f06d818 100644 (file)
@@ -927,13 +927,13 @@ render_page_unref (struct render_page *page)
 /* Returns the size of PAGE along AXIS.  (This might be larger than the page
    size specified in the parameters passed to render_page_create().  Use a
    render_break to break up a render_page into page-sized chunks.) */
-int
+static int
 render_page_get_size (const struct render_page *page, enum table_axis axis)
 {
   return page->cp[axis][page->n[axis] * 2 + 1];
 }
 
-int
+static int
 render_page_get_best_breakpoint (const struct render_page *page, int height)
 {
   int y;
@@ -1085,7 +1085,7 @@ render_page_draw_cells (const struct render_page *page,
 
 /* Renders PAGE, by calling the 'draw_line' and 'draw_cell' functions from the
    render_params provided to render_page_create(). */
-void
+static void
 render_page_draw (const struct render_page *page, int ofs[TABLE_N_AXES])
 {
   int bb[TABLE_N_AXES][2];
@@ -1151,7 +1151,7 @@ get_clip_max_extent (int x1, const int cp[], int n)
 /* Renders the cells of PAGE that intersect (X,Y)-(X+W,Y+H), by calling the
    'draw_line' and 'draw_cell' functions from the render_params provided to
    render_page_create(). */
-void
+static void
 render_page_draw_region (const struct render_page *page,
                          int ofs[TABLE_N_AXES], int clip[TABLE_N_AXES][2])
 {
@@ -1164,7 +1164,7 @@ render_page_draw_region (const struct render_page *page,
 
   render_page_draw_cells (page, ofs, bb);
 }
-\f
+
 /* Breaking up tables to fit on a page. */
 
 /* An iterator for breaking render_pages into smaller chunks. */
@@ -1416,12 +1416,15 @@ struct render_pager
     struct render_break y_break;
   };
 
-static void
+static const struct render_page *
 render_pager_add_table (struct render_pager *p, struct table *table)
 {
+  struct render_page *page;
+
   if (p->n_pages >= p->allocated_pages)
     p->pages = x2nrealloc (p->pages, &p->allocated_pages, sizeof *p->pages);
-  p->pages[p->n_pages++] = render_page_create (p->params, table);
+  page = p->pages[p->n_pages++] = render_page_create (p->params, table);
+  return page;
 }
 
 static void
@@ -1483,17 +1486,28 @@ struct render_pager *
 render_pager_create (const struct render_params *params,
                      const struct table_item *table_item)
 {
+  const char *caption = table_item_get_caption (table_item);
+  const char *title = table_item_get_title (table_item);
+  const struct render_page *body_page;
   struct render_pager *p;
-  const char *caption;
 
   p = xzalloc (sizeof *p);
   p->params = params;
 
-  caption = table_item_get_caption (table_item);
+  /* Title. */
+  if (title)
+    render_pager_add_table (p, table_from_string (TAB_LEFT, title));
+
+  /* Body. */
+  body_page = render_pager_add_table (p, table_ref (table_item_get_table (
+                                                      table_item)));
+
+  /* Caption. */
   if (caption)
     render_pager_add_table (p, table_from_string (TAB_LEFT, caption));
-  render_pager_add_table (p, table_ref (table_item_get_table (table_item)));
-  add_footnote_page (p, p->pages[p->n_pages - 1]);
+
+  /* Footnotes. */
+  add_footnote_page (p, body_page);
 
   render_pager_start_page (p);
 
@@ -1599,11 +1613,14 @@ render_pager_draw_region (const struct render_pager *p,
   for (i = 0; i < p->n_pages; i++)
     {
       const struct render_page *page = p->pages[i];
+      int size = render_page_get_size (page, V);
 
       clip[V][0] = MAX (y, ofs[V]) - ofs[V];
-      clip[V][1] = MIN (y + h, ofs[V] + render_page_get_size (page, V)) - ofs[V];
+      clip[V][1] = MIN (y + h, ofs[V] + size) - ofs[V];
       if (clip[V][1] > clip[V][0])
         render_page_draw_region (page, ofs, clip);
+
+      ofs[V] += size;
     }
 }