From a8799bb1d22a001fe846733bc127b203e3c5894a Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 2 Dec 2018 13:37:57 -0800 Subject: [PATCH] output: Remove support for nested tables. They are no longer used. --- src/output/ascii.c | 73 +----- src/output/cairo.c | 83 +------ src/output/csv.c | 92 +------ src/output/html.c | 61 +++-- src/output/odt.c | 24 +- src/output/tab.c | 58 +---- src/output/tab.h | 5 - src/output/table-casereader.c | 1 - src/output/table-provider.h | 5 +- src/output/table.c | 79 ------ src/output/table.h | 2 - tests/language/dictionary/sys-file-info.at | 2 - tests/output/render-test.c | 56 +---- tests/output/render.at | 276 --------------------- 14 files changed, 59 insertions(+), 758 deletions(-) diff --git a/src/output/ascii.c b/src/output/ascii.c index 897182d043..ae5e25bef4 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -646,7 +646,6 @@ ascii_measure_cell_width (void *a_, const struct table_cell *cell, ascii_layout_cell (a, cell, footnote_idx, bb, clip, max_width, &h); if (cell->n_contents != 1 - || cell->contents[0].table || cell->contents[0].n_footnotes || strchr (cell->contents[0].text, ' ')) { @@ -945,69 +944,6 @@ ascii_layout_cell_text (struct ascii_driver *a, return y; } -static int -ascii_layout_subtable (struct ascii_driver *a, - const struct cell_contents *contents, - int *footnote_idx UNUSED /* XXX */, - int bb[TABLE_N_AXES][2], int clip[TABLE_N_AXES][2] UNUSED, - int *widthp) -{ - struct render_params params; - struct render_pager *p; - int r[TABLE_N_AXES][2]; - int width, height; - int i; - - params.draw_line = ascii_draw_line; - params.measure_cell_width = ascii_measure_cell_width; - params.measure_cell_height = ascii_measure_cell_height; - params.adjust_break = NULL; - params.draw_cell = ascii_draw_cell, - params.aux = a; - params.size[H] = bb[TABLE_HORZ][1] - bb[TABLE_HORZ][0]; - params.size[V] = bb[TABLE_VERT][1] - bb[TABLE_VERT][0]; - params.font_size[H] = 1; - params.font_size[V] = 1; - for (i = 0; i < RENDER_N_LINES; i++) - { - int width = i == RENDER_LINE_NONE ? 0 : 1; - params.line_widths[H][i] = width; - params.line_widths[V][i] = width; - } - - p = render_pager_create (¶ms, contents->table); - width = render_pager_get_size (p, TABLE_HORZ); - height = render_pager_get_size (p, TABLE_VERT); - - /* r = intersect(bb, clip) - bb. */ - for (i = 0; i < TABLE_N_AXES; i++) - { - r[i][0] = MAX (bb[i][0], clip[i][0]) - bb[i][0]; - r[i][1] = MIN (bb[i][1], clip[i][1]) - bb[i][0]; - } - - if (r[H][0] < r[H][1] && r[V][0] < r[V][1]) - { - unsigned int alignment = contents->options & TAB_ALIGNMENT; - int save_x = a->x; - - a->x += bb[TABLE_HORZ][0]; - if (alignment == TAB_RIGHT) - a->x += params.size[H] - width; - else if (alignment == TAB_CENTER) - a->x += (params.size[H] - width) / 2; - a->y += bb[TABLE_VERT][0]; - render_pager_draw (p); - a->y -= bb[TABLE_VERT][0]; - a->x = save_x; - } - render_pager_destroy (p); - - if (width > *widthp) - *widthp = width; - return bb[V][0] + height; -} - static void ascii_layout_cell (struct ascii_driver *a, const struct table_cell *cell, int footnote_idx, @@ -1033,12 +969,8 @@ ascii_layout_cell (struct ascii_driver *a, const struct table_cell *cell, break; } - if (contents->text) - bb[V][0] = ascii_layout_cell_text (a, contents, &footnote_idx, - bb, clip, widthp); - else - bb[V][0] = ascii_layout_subtable (a, contents, &footnote_idx, - bb, clip, widthp); + bb[V][0] = ascii_layout_cell_text (a, contents, &footnote_idx, + bb, clip, widthp); } *heightp = bb[V][0] - bb_[V][0]; } @@ -1059,7 +991,6 @@ ascii_test_write (struct output_driver *driver, contents.options = options | TAB_LEFT; contents.text = CONST_CAST (char *, s); - contents.table = NULL; contents.n_footnotes = 0; memset (&cell, 0, sizeof cell); diff --git a/src/output/cairo.c b/src/output/cairo.c index ef0b593233..49a7f7ed3d 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -1105,81 +1105,6 @@ xr_layout_cell_text (struct xr_driver *xr, return y + h; } -static int -xr_layout_cell_subtable (struct xr_driver *xr, - const struct cell_contents *contents, - int footnote_idx UNUSED, - int bb[TABLE_N_AXES][2], - int clip[TABLE_N_AXES][2], int *widthp, int *brk) -{ - int single_width, double_width; - struct render_params params; - struct render_pager *p; - int r[TABLE_N_AXES][2]; - int width, height; - int i; - - params.draw_line = xr_draw_line; - params.measure_cell_width = xr_measure_cell_width; - params.measure_cell_height = xr_measure_cell_height; - params.adjust_break = NULL; - params.draw_cell = xr_draw_cell; - params.aux = xr; - params.size[H] = bb[H][1] - bb[H][0]; - params.size[V] = bb[V][1] - bb[V][0]; - params.font_size[H] = xr->char_width; - params.font_size[V] = xr->char_height; - - single_width = 2 * xr->line_gutter + xr->line_width; - double_width = 2 * xr->line_gutter + xr->line_space + 2 * xr->line_width; - for (i = 0; i < TABLE_N_AXES; i++) - { - params.line_widths[i][RENDER_LINE_NONE] = 0; - params.line_widths[i][RENDER_LINE_SINGLE] = single_width; - params.line_widths[i][RENDER_LINE_DOUBLE] = double_width; - } - - xr->nest++; - p = render_pager_create (¶ms, contents->table); - width = render_pager_get_size (p, H); - height = render_pager_get_size (p, V); - if (bb[V][0] + height >= bb[V][1]) - *brk = bb[V][0] + render_pager_get_best_breakpoint (p, bb[V][1] - bb[V][0]); - - /* r = intersect(bb, clip) - bb. */ - for (i = 0; i < TABLE_N_AXES; i++) - { - r[i][0] = MAX (bb[i][0], clip[i][0]) - bb[i][0]; - r[i][1] = MIN (bb[i][1], clip[i][1]) - bb[i][0]; - } - - if (r[H][0] < r[H][1] && r[V][0] < r[V][1]) - { - unsigned int alignment = contents->options & TAB_ALIGNMENT; - int save_x = xr->x; - - cairo_save (xr->cairo); - xr_clip (xr, clip); - xr->x += bb[H][0]; - if (alignment == TAB_RIGHT) - xr->x += params.size[H] - width; - else if (alignment == TAB_CENTER) - xr->x += (params.size[H] - width) / 2; - xr->y += bb[V][0]; - render_pager_draw_region (p, r[H][0], r[V][0], - r[H][1] - r[H][0], r[V][1] - r[V][0]); - xr->y -= bb[V][0]; - xr->x = save_x; - cairo_restore (xr->cairo); - } - render_pager_destroy (p); - xr->nest--; - - if (width > *widthp) - *widthp = width; - return bb[V][0] + height; -} - static void xr_layout_cell (struct xr_driver *xr, const struct table_cell *cell, int footnote_idx, @@ -1228,12 +1153,8 @@ xr_layout_cell (struct xr_driver *xr, const struct table_cell *cell, *brk = bb[V][0]; } - if (contents->text) - bb[V][0] = xr_layout_cell_text (xr, contents, footnote_idx, bb, clip, - bb[V][0], width, brk); - else - bb[V][0] = xr_layout_cell_subtable (xr, contents, footnote_idx, - bb, clip, width, brk); + bb[V][0] = xr_layout_cell_text (xr, contents, footnote_idx, bb, clip, + bb[V][0], width, brk); footnote_idx += contents->n_footnotes; } *height = bb[V][0] - bb_[V][0]; diff --git a/src/output/csv.c b/src/output/csv.c index 455584914e..d463a3f6de 100644 --- a/src/output/csv.c +++ b/src/output/csv.c @@ -164,93 +164,6 @@ csv_output_field_format (struct csv_driver *csv, const char *format, ...) free (s); } -static void -csv_put_field (struct csv_driver *csv, struct string *s, const char *field) -{ - while (*field == ' ') - field++; - - if (csv->quote && field[strcspn (field, csv->quote_set)]) - { - const char *p; - - ds_put_byte (s, csv->quote); - for (p = field; *p != '\0'; p++) - { - if (*p == csv->quote) - ds_put_byte (s, csv->quote); - ds_put_byte (s, *p); - } - ds_put_byte (s, csv->quote); - } - else - ds_put_cstr (s, field); -} - -static void -csv_output_subtable (struct csv_driver *csv, struct string *s, - const struct table_item *item) -{ - const struct table *t = table_item_get_table (item); - const char *title = table_item_get_title (item); - const char *caption = table_item_get_caption (item); - int y, x; - - if (csv->titles && title != NULL) - { - csv_output_field_format (csv, "Table: %s", title); - putc ('\n', csv->file); - } - - for (y = 0; y < table_nr (t); y++) - { - if (y > 0) - ds_put_byte (s, '\n'); - - for (x = 0; x < table_nc (t); x++) - { - struct table_cell cell; - - table_get_cell (t, x, y, &cell); - - if (x > 0) - ds_put_cstr (s, csv->separator); - - if (x != cell.d[TABLE_HORZ][0] || y != cell.d[TABLE_VERT][0]) - csv_put_field (csv, s, ""); - else if (cell.n_contents == 1 && cell.contents[0].text != NULL) - csv_put_field (csv, s, cell.contents[0].text); - else - { - struct string s2; - size_t i; - - ds_init_empty (&s2); - for (i = 0; i < cell.n_contents; i++) - { - if (i > 0) - ds_put_cstr (&s2, "\n\n"); - - if (cell.contents[i].text != NULL) - ds_put_cstr (&s2, cell.contents[i].text); - else - csv_output_subtable (csv, &s2, cell.contents[i].table); - } - csv_put_field (csv, s, ds_cstr (&s2)); - ds_destroy (&s2); - } - - table_cell_free (&cell); - } - } - - if (csv->captions && caption != NULL) - { - csv_output_field_format (csv, "Caption: %s", caption); - putc ('\n', csv->file); - } -} - static void csv_put_separator (struct csv_driver *csv) { @@ -315,10 +228,7 @@ csv_submit (struct output_driver *driver, if (i > 0) ds_put_cstr (&s, "\n\n"); - if (c->text != NULL) - ds_put_cstr (&s, c->text); - else - csv_output_subtable (csv, &s, c->table); + ds_put_cstr (&s, c->text); for (j = 0; j < c->n_footnotes; j++) { diff --git a/src/output/html.c b/src/output/html.c index 38b89719a4..6dc2ffe737 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -527,45 +527,40 @@ html_output_table (struct html_driver *html, const struct table_item *item) /* Output cell contents. */ for (c = cell.contents; c < &cell.contents[cell.n_contents]; c++) { - if (c->text) + const char *s = c->text; + int i; + + if (c->options & TAB_EMPH) + fputs ("", html->file); + if (c->options & TAB_FIX) + { + fputs ("", html->file); + escape_string (html->file, s, strlen (s), " ", "
"); + fputs ("
", html->file); + } + else { - const char *s = c->text; - int i; + s += strspn (s, CC_SPACES); + escape_string (html->file, s, strlen (s), " ", "
"); + } + if (c->options & TAB_EMPH) + fputs ("
", html->file); - if (c->options & TAB_EMPH) - fputs ("", html->file); - if (c->options & TAB_FIX) - { - fputs ("", html->file); - escape_string (html->file, s, strlen (s), " ", "
"); - fputs ("
", html->file); - } - else + if (c->n_footnotes > 0) + { + fputs ("", html->file); + for (i = 0; i < c->n_footnotes; i++) { - s += strspn (s, CC_SPACES); - escape_string (html->file, s, strlen (s), " ", "
"); - } - if (c->options & TAB_EMPH) - fputs ("
", html->file); + char marker[16]; - if (c->n_footnotes > 0) - { - fputs ("", html->file); - for (i = 0; i < c->n_footnotes; i++) - { - char marker[16]; - - if (i > 0) - putc (',', html->file); - str_format_26adic (++footnote_idx, false, - marker, sizeof marker); - fputs (marker, html->file); - } - fputs ("", html->file); + if (i > 0) + putc (',', html->file); + str_format_26adic (++footnote_idx, false, + marker, sizeof marker); + fputs (marker, html->file); } + fputs ("", html->file); } - else - html_output_table (html, c->table); } /* Output or . */ diff --git a/src/output/odt.c b/src/output/odt.c index 065ef379a6..63c10054f9 100644 --- a/src/output/odt.c +++ b/src/output/odt.c @@ -526,25 +526,19 @@ write_table (struct odt_driver *odt, const struct table_item *item) const struct cell_contents *contents = &cell.contents[i]; int j; - if (contents->text) - { - xmlTextWriterStartElement (odt->content_wtr, _xml("text:p")); + xmlTextWriterStartElement (odt->content_wtr, _xml("text:p")); - if ( r < table_ht (tab) || c < table_hl (tab) ) - xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"), _xml("Table_20_Heading")); - else - xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"), _xml("Table_20_Contents")); + if ( r < table_ht (tab) || c < table_hl (tab) ) + xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"), _xml("Table_20_Heading")); + else + xmlTextWriterWriteAttribute (odt->content_wtr, _xml("text:style-name"), _xml("Table_20_Contents")); - write_xml_with_line_breaks (odt, contents->text); + write_xml_with_line_breaks (odt, contents->text); - for (j = 0; j < contents->n_footnotes; j++) - write_footnote (odt, contents->footnotes[j]); - - xmlTextWriterEndElement (odt->content_wtr); /* text:p */ - } - else if (contents->table) - write_table (odt, contents->table); + for (j = 0; j < contents->n_footnotes; j++) + write_footnote (odt, contents->footnotes[j]); + xmlTextWriterEndElement (odt->content_wtr); /* text:p */ } xmlTextWriterEndElement (odt->content_wtr); /* table:table-cell */ } diff --git a/src/output/tab.c b/src/output/tab.c index 733cc9854f..78bde01e5d 100644 --- a/src/output/tab.c +++ b/src/output/tab.c @@ -53,8 +53,6 @@ static const bool debugging = false; /* Cell options. */ #define TAB_JOIN (1u << TAB_FIRST_AVAILABLE) -#define TAB_SUBTABLE (1u << (TAB_FIRST_AVAILABLE + 1)) -#define TAB_BARE (1u << (TAB_FIRST_AVAILABLE + 2)) /* Joined cell. */ struct tab_joined_cell @@ -643,39 +641,6 @@ tab_footnote (struct tab_table *table, int x, int y, const char *format, ...) va_end (args); } -static void -subtable_unref (void *subtable) -{ - table_item_unref (subtable); -} - -/* Places SUBTABLE as the content for cells (X1,X2)-(Y1,Y2) inclusive in TABLE - with options OPT. */ -void -tab_subtable (struct tab_table *table, int x1, int y1, int x2, int y2, - unsigned opt, struct table_item *subtable) -{ - add_joined_cell (table, x1, y1, x2, y2, opt | TAB_SUBTABLE)->u.subtable - = subtable; - pool_register (table->container, subtable_unref, subtable); -} - -/* Places the contents of SUBTABLE as the content for cells (X1,X2)-(Y1,Y2) - inclusive in TABLE with options OPT. - - SUBTABLE must have exactly one row and column. The contents of its single - cell are used as the contents of TABLE's cell; that is, SUBTABLE is not used - as a nested table but its contents become part of TABLE. */ -void -tab_subtable_bare (struct tab_table *table, int x1, int y1, int x2, int y2, - unsigned opt, struct table_item *subtable) -{ - const struct table *t UNUSED = table_item_get_table (subtable); - assert (table_nc (t) == 1); - assert (table_nr (t) == 1); - tab_subtable (table, x1, y1, x2, y2, opt | TAB_BARE, subtable); -} - bool tab_cell_is_empty (const struct tab_table *table, int c, int r) { @@ -815,32 +780,15 @@ tab_get_cell (const struct table *table, int x, int y, const void *cc = t->cc[index]; cell->inline_contents.options = opt; - cell->inline_contents.table = NULL; cell->inline_contents.n_footnotes = 0; cell->destructor = NULL; if (opt & TAB_JOIN) { const struct tab_joined_cell *jc = cc; - if (opt & TAB_BARE) - { - assert (opt & TAB_SUBTABLE); - - /* This overwrites all of the members of CELL. */ - table_get_cell (table_item_get_table (jc->u.subtable), 0, 0, cell); - } - else - { - cell->contents = &cell->inline_contents; - cell->n_contents = 1; - if (opt & TAB_SUBTABLE) - { - cell->inline_contents.table = jc->u.subtable; - cell->inline_contents.text = NULL; - } - else - cell->inline_contents.text = jc->u.text; - } + cell->contents = &cell->inline_contents; + cell->n_contents = 1; + cell->inline_contents.text = jc->u.text; cell->inline_contents.footnotes = jc->footnotes; cell->inline_contents.n_footnotes = jc->n_footnotes; diff --git a/src/output/tab.h b/src/output/tab.h index 9371d812c6..3109e39439 100644 --- a/src/output/tab.h +++ b/src/output/tab.h @@ -146,11 +146,6 @@ void tab_joint_text_format (struct tab_table *, int x1, int y1, int x2, int y2, void tab_footnote (struct tab_table *, int x, int y, const char *format, ...) PRINTF_FORMAT (4, 5); -void tab_subtable (struct tab_table *, int x1, int y1, int x2, int y2, - unsigned opt, struct table_item *subtable); -void tab_subtable_bare (struct tab_table *, int x1, int y1, int x2, int y2, - unsigned opt, struct table_item *subtable); - bool tab_cell_is_empty (const struct tab_table *, int c, int r); /* Editing. */ diff --git a/src/output/table-casereader.c b/src/output/table-casereader.c index 485014dc81..36f74f20c4 100644 --- a/src/output/table-casereader.c +++ b/src/output/table-casereader.c @@ -113,7 +113,6 @@ table_casereader_get_cell (const struct table *t, int x, int y, cell->contents = &cell->inline_contents; cell->n_contents = 1; cell->inline_contents.options = TAB_RIGHT; - cell->inline_contents.table = NULL; cell->inline_contents.n_footnotes = 0; if (tc->heading != NULL) { diff --git a/src/output/table-provider.h b/src/output/table-provider.h index b64410c227..5dbf99b15a 100644 --- a/src/output/table-provider.h +++ b/src/output/table-provider.h @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997, 1998, 1999, 2000, 2009, 2011, 2013, 2014 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2009, 2011, 2013, 2014, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,10 +23,7 @@ struct cell_contents { unsigned int options; /* TAB_*. */ - - /* Exactly one of these must be nonnull. */ char *text; /* A paragraph of text. */ - struct table_item *table; /* A table nested within the cell. */ /* Optional footnote(s). */ char **footnotes; diff --git a/src/output/table.c b/src/output/table.c index e354bb3edf..2158ca723e 100644 --- a/src/output/table.c +++ b/src/output/table.c @@ -320,7 +320,6 @@ table_string_get_cell (const struct table *ts_, int x UNUSED, int y UNUSED, cell->contents = &cell->inline_contents; cell->inline_contents.options = ts->options; cell->inline_contents.text = ts->string; - cell->inline_contents.table = NULL; cell->inline_contents.n_footnotes = 0; cell->n_contents = 1; cell->destructor = NULL; @@ -342,81 +341,3 @@ static const struct table_class table_string_class = NULL, /* paste */ NULL, /* select */ }; - -struct table_nested - { - struct table table; - struct table_item *inner; - }; - -static const struct table_class table_nested_class; - -/* Creates and returns a table with a single cell that contains INNER. - Takes ownership of INNER. */ -struct table * -table_create_nested (struct table *inner) -{ - return table_create_nested_item (table_item_create (inner, NULL, NULL)); -} - -/* Creates and returns a table with a single cell that contains INNER. - Takes ownership of INNER. */ -struct table * -table_create_nested_item (struct table_item *inner) -{ - struct table_nested *tn = xmalloc (sizeof *tn); - table_init (&tn->table, &table_nested_class); - tn->table.n[TABLE_HORZ] = tn->table.n[TABLE_VERT] = 1; - tn->inner = inner; - return &tn->table; -} - -static struct table_nested * -table_nested_cast (const struct table *table) -{ - assert (table->klass == &table_nested_class); - return UP_CAST (table, struct table_nested, table); -} - -static void -table_nested_destroy (struct table *tn_) -{ - struct table_nested *tn = table_nested_cast (tn_); - table_item_unref (tn->inner); - free (tn); -} - -static void -table_nested_get_cell (const struct table *tn_, int x UNUSED, int y UNUSED, - struct table_cell *cell) -{ - struct table_nested *tn = table_nested_cast (tn_); - cell->d[TABLE_HORZ][0] = 0; - cell->d[TABLE_HORZ][1] = 1; - cell->d[TABLE_VERT][0] = 0; - cell->d[TABLE_VERT][1] = 1; - cell->contents = &cell->inline_contents; - cell->inline_contents.options = TAB_LEFT; - cell->inline_contents.text = NULL; - cell->inline_contents.table = tn->inner; - cell->inline_contents.n_footnotes = 0; - cell->n_contents = 1; - cell->destructor = NULL; -} - -static int -table_nested_get_rule (const struct table *tn UNUSED, - enum table_axis axis UNUSED, int x UNUSED, int y UNUSED) -{ - return TAL_0; -} - -static const struct table_class table_nested_class = - { - table_nested_destroy, - table_nested_get_cell, - table_nested_get_rule, - NULL, /* paste */ - NULL, /* select */ - }; - diff --git a/src/output/table.h b/src/output/table.h index 919777db53..09e5041a3e 100644 --- a/src/output/table.h +++ b/src/output/table.h @@ -171,8 +171,6 @@ struct table *table_from_casereader (const struct casereader *, size_t column, const char *heading, const struct fmt_spec *); -struct table *table_create_nested (struct table *); -struct table *table_create_nested_item (struct table_item *); /* Combining tables. */ struct table *table_paste (struct table *, struct table *, diff --git a/tests/language/dictionary/sys-file-info.at b/tests/language/dictionary/sys-file-info.at index 25e38e45fe..d71e813743 100644 --- a/tests/language/dictionary/sys-file-info.at +++ b/tests/language/dictionary/sys-file-info.at @@ -29,8 +29,6 @@ SAVE OUTFILE='pro.sav'. sysfile info file='pro.sav'. ]) AT_CHECK([pspp -o pspp.csv sysfile-info.sps]) -AT_CHECK([pspp -o pspp.pdf sysfile-info.sps]) -AT_CHECK([pspp -o pspp.txt sysfile-info.sps]) AT_CHECK( [sed -e '/^Created:,/d' \ -e '/^Endian:,/d' \ diff --git a/tests/output/render-test.c b/tests/output/render-test.c index fdfb2d20b6..2c68381331 100644 --- a/tests/output/render-test.c +++ b/tests/output/render-test.c @@ -67,7 +67,7 @@ static const char *output_base = "render"; static const char *parse_options (int argc, char **argv); static void usage (void) NO_RETURN; -static struct table *read_table (FILE *, struct table **tables, size_t n_tables); +static struct table *read_table (FILE *); static void draw (FILE *); int @@ -103,7 +103,7 @@ main (int argc, char **argv) if (n_tables >= allocated_tables) tables = x2nrealloc (tables, &allocated_tables, sizeof *tables); - tables[n_tables] = read_table (input, tables, n_tables); + tables[n_tables] = read_table (input); n_tables++; ch = getc (input); @@ -351,7 +351,7 @@ replace_newlines (char *p) } static struct table * -read_table (FILE *stream, struct table **tables, size_t n_tables) +read_table (FILE *stream) { struct tab_table *tab; char buffer[1024]; @@ -381,7 +381,6 @@ read_table (FILE *stream, struct table **tables, size_t n_tables) { unsigned int opt; char *new_line; - unsigned int i; char *text; int rs, cs; @@ -452,45 +451,16 @@ read_table (FILE *stream, struct table **tables, size_t n_tables) replace_newlines (text); - if (sscanf (text, "{%u}", &i) == 1) - { - struct table *table; - - if (i >= n_tables) - error (1, 0, "bad table number %u", i); - table = table_ref (tables[i]); - - text = strchr (text, '}') + 1; - while (*text) - switch (*text++) - { - case 's': - table = table_stomp (table); - break; - - case 't': - table = table_transpose (table); - break; - - default: - error (1, 0, "unexpected subtable modifier \"%c\"", *text); - } - tab_subtable (tab, c, r, c + cs - 1, r + rs - 1, opt, - table_item_create (table, NULL, NULL)); - } - else - { - char *pos = text; - char *content; - int i; - - for (i = 0; (content = strsep (&pos, "#")) != NULL; i++) - if (!i) - tab_joint_text (tab, c, r, c + cs - 1, r + rs - 1, opt, - content); - else - tab_footnote (tab, c, r, "%s", content); - } + char *pos = text; + char *content; + int i; + + for (i = 0; (content = strsep (&pos, "#")) != NULL; i++) + if (!i) + tab_joint_text (tab, c, r, c + cs - 1, r + rs - 1, opt, + content); + else + tab_footnote (tab, c, r, "%s", content); } return &tab->table; diff --git a/tests/output/render.at b/tests/output/render.at index b2c9731ce0..e1d6fcea36 100644 --- a/tests/output/render.at +++ b/tests/output/render.at @@ -182,17 +182,6 @@ AT_CHECK([render-test input], [0], [abc ]) AT_CLEANUP -AT_SETUP([nested single cell]) -AT_KEYWORDS([render rendering]) -AT_DATA([input], [1 1 -abc -1 1 -{0} -]) -AT_CHECK([render-test input], [0], [abc -]) -AT_CLEANUP - AT_SETUP([single cell with border]) AT_KEYWORDS([render rendering]) AT_DATA([input], [1 1 @@ -205,22 +194,6 @@ AT_CHECK([render-test input], [0], [dnl ]) AT_CLEANUP -AT_SETUP([nested single cell with border]) -AT_KEYWORDS([render rendering]) -AT_DATA([input], [1 1 -@abc -1 1 -@{0} -]) -AT_CHECK([render-test input], [0], [dnl -+-----+ -|+---+| -||abc|| -|+---+| -+-----+ -]) -AT_CLEANUP - AT_SETUP([joined columns]) AT_KEYWORDS([render rendering]) AT_DATA([input], [2 2 @@ -406,26 +379,6 @@ AT_CHECK([render-test input], [0], [dnl ]) AT_CLEANUP -AT_SETUP([nested joined rows]) -AT_KEYWORDS([render rendering]) -AT_DATA([input], [2 2 -2*1 @ab\ncd\nef -@hij -@klm -1 1 -@{0} -]) -AT_CHECK([render-test input], [0], [dnl -+--------+ -|+--+---+| -||ab|hij|| -||cd+---+| -||ef|klm|| -|+--+---+| -+--------+ -]) -AT_CLEANUP - dnl This checks for bug #31346, a segmentation fault that surfaced dnl when two or more rows had no unspanned cells and no rules. AT_SETUP([joined rows only, no rules]) @@ -567,203 +520,6 @@ AT_CHECK([render-test input], [0],[dnl +-----+------+----+ ]) AT_CLEANUP - -AT_SETUP([nested 8x8]) -AT_KEYWORDS([render rendering]) -AT_DATA([input], [WEAVE_8X8[]dnl -1 1 -@{0} -]) -AT_CHECK([render-test input], [0], [dnl -+-----------------+ -|+-+-+-+-+-+-+-+-+| -||a|b|c|d|e|f|g|h|| -|+-+-+-+-+-+-+-+-+| -||i|jkl|m|nop|q|t|| -|+-+-+-+-+-+-+r+-+| -||u|v|wxy|z|A|s|D|| -|+-+-+-+-+-+B+-+-+| -||E|F|I|JKL|C|M|P|| -|+-+G+-+---+-+N+-+| -||Q|H|R|UVW|X|O|Y|| -|+-+-+S+-+-+-+-+-+| -||Z|0|T|3|456|7|8|| -|+-+1+-+-+-+-+-+-+| -||9|2|abc|d|efg|h|| -|+-+-+-+-+-+-+-+-+| -||i|j|k|l|m|n|o|p|| -|+-+-+-+-+-+-+-+-+| -+-----------------+ -]) -AT_CLEANUP - -AT_SETUP([nested 8x8s and 6x6s]) -AT_KEYWORDS([render rendering]) -AT_DATA([input], [WEAVE_8X8[]WEAVE_6X6[]dnl -4 2 -@{0} -@{1} -@{1} -@|{1} -@|{1} -@({1} -@({1} -@{0} -]) -AT_CHECK([render-test input], [0], [dnl -+-----------------+-----------------+ -|+-+-+-+-+-+-+-+-+| +-+---+-+-+-+| -||a|b|c|d|e|f|g|h|| |a|bcd|e|f|i|| -|+-+-+-+-+-+-+-+-+| +-+-+-+-+g+-+| -||i|jkl|m|nop|q|t|| |j|m|nop|h|q|| -|+-+-+-+-+-+-+r+-+| |k+-+-+-+-+r|| -||u|v|wxy|z|A|s|D|| |l|t|w|xyz|s|| -|+-+-+-+-+-+B+-+-+| +-+u+-+-+-+-+| -||E|F|I|JKL|C|M|P|| |A|v|B|E|FGH|| -|+-+G+-+---+-+N+-+| +-+-+C+-+-+-+| -||Q|H|R|UVW|X|O|Y|| |IJK|D|L|O|P|| -|+-+-+S+-+-+-+-+-+| +-+-+-+M+-+-+| -||Z|0|T|3|456|7|8|| |Q|RST|N|U|V|| -|+-+1+-+-+-+-+-+-+| +-+---+-+-+-+| -||9|2|abc|d|efg|h|| | -|+-+-+-+-+-+-+-+-+| | -||i|j|k|l|m|n|o|p|| | -|+-+-+-+-+-+-+-+-+| | -+-----------------+-----------------+ -| +-+---+-+-+-+| +-+---+-+-+-+ | -| |a|bcd|e|f|i|| |a|bcd|e|f|i| | -| +-+-+-+-+g+-+| +-+-+-+-+g+-+ | -| |j|m|nop|h|q|| |j|m|nop|h|q| | -| |k+-+-+-+-+r|| |k+-+-+-+-+r| | -| |l|t|w|xyz|s|| |l|t|w|xyz|s| | -| +-+u+-+-+-+-+| +-+u+-+-+-+-+ | -| |A|v|B|E|FGH|| |A|v|B|E|FGH| | -| +-+-+C+-+-+-+| +-+-+C+-+-+-+ | -| |IJK|D|L|O|P|| |IJK|D|L|O|P| | -| +-+-+-+M+-+-+| +-+-+-+M+-+-+ | -| |Q|RST|N|U|V|| |Q|RST|N|U|V| | -| +-+---+-+-+-+| +-+---+-+-+-+ | -+-----------------+-----------------+ -| +-+---+-+-+-+ |+-+---+-+-+-+ | -| |a|bcd|e|f|i| ||a|bcd|e|f|i| | -| +-+-+-+-+g+-+ |+-+-+-+-+g+-+ | -| |j|m|nop|h|q| ||j|m|nop|h|q| | -| |k+-+-+-+-+r| ||k+-+-+-+-+r| | -| |l|t|w|xyz|s| ||l|t|w|xyz|s| | -| +-+u+-+-+-+-+ |+-+u+-+-+-+-+ | -| |A|v|B|E|FGH| ||A|v|B|E|FGH| | -| +-+-+C+-+-+-+ |+-+-+C+-+-+-+ | -| |IJK|D|L|O|P| ||IJK|D|L|O|P| | -| +-+-+-+M+-+-+ |+-+-+-+M+-+-+ | -| |Q|RST|N|U|V| ||Q|RST|N|U|V| | -| +-+---+-+-+-+ |+-+---+-+-+-+ | -+-----------------+-----------------+ -|+-+---+-+-+-+ |+-+-+-+-+-+-+-+-+| -||a|bcd|e|f|i| ||a|b|c|d|e|f|g|h|| -|+-+-+-+-+g+-+ |+-+-+-+-+-+-+-+-+| -||j|m|nop|h|q| ||i|jkl|m|nop|q|t|| -||k+-+-+-+-+r| |+-+-+-+-+-+-+r+-+| -||l|t|w|xyz|s| ||u|v|wxy|z|A|s|D|| -|+-+u+-+-+-+-+ |+-+-+-+-+-+B+-+-+| -||A|v|B|E|FGH| ||E|F|I|JKL|C|M|P|| -|+-+-+C+-+-+-+ |+-+G+-+---+-+N+-+| -||IJK|D|L|O|P| ||Q|H|R|UVW|X|O|Y|| -|+-+-+-+M+-+-+ |+-+-+S+-+-+-+-+-+| -||Q|RST|N|U|V| ||Z|0|T|3|456|7|8|| -|+-+---+-+-+-+ |+-+1+-+-+-+-+-+-+| -| ||9|2|abc|d|efg|h|| -| |+-+-+-+-+-+-+-+-+| -| ||i|j|k|l|m|n|o|p|| -| |+-+-+-+-+-+-+-+-+| -+-----------------+-----------------+ -]) -AT_CLEANUP - -AT_SETUP([doubly nested cells]) -AT_KEYWORDS([render rendering]) -AT_DATA([input], [WEAVE_8X8[]WEAVE_6X6[]dnl -4 2 -@{0} -@{1} -@{1} -@|{1} -@|{1} -@({1} -@({1} -@{0} -1 1 -@{2} -]) -AT_CHECK([render-test input --length=70], [0], [dnl -+-------------------------------------+ -|+-----------------+-----------------+| -||+-+-+-+-+-+-+-+-+| +-+---+-+-+-+|| -|||a|b|c|d|e|f|g|h|| |a|bcd|e|f|i||| -||+-+-+-+-+-+-+-+-+| +-+-+-+-+g+-+|| -|||i|jkl|m|nop|q|t|| |j|m|nop|h|q||| -||+-+-+-+-+-+-+r+-+| |k+-+-+-+-+r||| -|||u|v|wxy|z|A|s|D|| |l|t|w|xyz|s||| -||+-+-+-+-+-+B+-+-+| +-+u+-+-+-+-+|| -|||E|F|I|JKL|C|M|P|| |A|v|B|E|FGH||| -||+-+G+-+---+-+N+-+| +-+-+C+-+-+-+|| -|||Q|H|R|UVW|X|O|Y|| |IJK|D|L|O|P||| -||+-+-+S+-+-+-+-+-+| +-+-+-+M+-+-+|| -|||Z|0|T|3|456|7|8|| |Q|RST|N|U|V||| -||+-+1+-+-+-+-+-+-+| +-+---+-+-+-+|| -|||9|2|abc|d|efg|h|| || -||+-+-+-+-+-+-+-+-+| || -|||i|j|k|l|m|n|o|p|| || -||+-+-+-+-+-+-+-+-+| || -|+-----------------+-----------------+| -|| +-+---+-+-+-+| +-+---+-+-+-+ || -|| |a|bcd|e|f|i|| |a|bcd|e|f|i| || -|| +-+-+-+-+g+-+| +-+-+-+-+g+-+ || -|| |j|m|nop|h|q|| |j|m|nop|h|q| || -|| |k+-+-+-+-+r|| |k+-+-+-+-+r| || -|| |l|t|w|xyz|s|| |l|t|w|xyz|s| || -|| +-+u+-+-+-+-+| +-+u+-+-+-+-+ || -|| |A|v|B|E|FGH|| |A|v|B|E|FGH| || -|| +-+-+C+-+-+-+| +-+-+C+-+-+-+ || -|| |IJK|D|L|O|P|| |IJK|D|L|O|P| || -|| +-+-+-+M+-+-+| +-+-+-+M+-+-+ || -|| |Q|RST|N|U|V|| |Q|RST|N|U|V| || -|| +-+---+-+-+-+| +-+---+-+-+-+ || -|+-----------------+-----------------+| -|| +-+---+-+-+-+ |+-+---+-+-+-+ || -|| |a|bcd|e|f|i| ||a|bcd|e|f|i| || -|| +-+-+-+-+g+-+ |+-+-+-+-+g+-+ || -|| |j|m|nop|h|q| ||j|m|nop|h|q| || -|| |k+-+-+-+-+r| ||k+-+-+-+-+r| || -|| |l|t|w|xyz|s| ||l|t|w|xyz|s| || -|| +-+u+-+-+-+-+ |+-+u+-+-+-+-+ || -|| |A|v|B|E|FGH| ||A|v|B|E|FGH| || -|| +-+-+C+-+-+-+ |+-+-+C+-+-+-+ || -|| |IJK|D|L|O|P| ||IJK|D|L|O|P| || -|| +-+-+-+M+-+-+ |+-+-+-+M+-+-+ || -|| |Q|RST|N|U|V| ||Q|RST|N|U|V| || -|| +-+---+-+-+-+ |+-+---+-+-+-+ || -|+-----------------+-----------------+| -||+-+---+-+-+-+ |+-+-+-+-+-+-+-+-+|| -|||a|bcd|e|f|i| ||a|b|c|d|e|f|g|h||| -||+-+-+-+-+g+-+ |+-+-+-+-+-+-+-+-+|| -|||j|m|nop|h|q| ||i|jkl|m|nop|q|t||| -|||k+-+-+-+-+r| |+-+-+-+-+-+-+r+-+|| -|||l|t|w|xyz|s| ||u|v|wxy|z|A|s|D||| -||+-+u+-+-+-+-+ |+-+-+-+-+-+B+-+-+|| -|||A|v|B|E|FGH| ||E|F|I|JKL|C|M|P||| -||+-+-+C+-+-+-+ |+-+G+-+---+-+N+-+|| -|||IJK|D|L|O|P| ||Q|H|R|UVW|X|O|Y||| -||+-+-+-+M+-+-+ |+-+-+S+-+-+-+-+-+|| -|||Q|RST|N|U|V| ||Z|0|T|3|456|7|8||| -||+-+---+-+-+-+ |+-+1+-+-+-+-+-+-+|| -|| ||9|2|abc|d|efg|h||| -|| |+-+-+-+-+-+-+-+-+|| -|| ||i|j|k|l|m|n|o|p||| -|| |+-+-+-+-+-+-+-+-+|| -|+-----------------+-----------------+| -+-------------------------------------+ -]) -AT_CLEANUP AT_BANNER([output rendering -- horizontal page breaks]) @@ -2392,38 +2148,6 @@ AT_CHECK([render-test --width=7 --length=6 input], [0], [expout]) AT_CHECK([render-test -o mb0 --min-break=0 --width=7 --length=6 input], [0], [expout]) AT_CLEANUP - -AT_SETUP([breaking nested cell too tall for page]) -AT_KEYWORDS([render rendering]) -AT_CAPTURE_FILE([input]) -AT_DATA([input], [WEAVE_8X8[]WEAVE_6X6[]dnl -1 2 -@{0} -@{1} -]) -AT_CHECK([render-test input --length=10], [0], [dnl -+-----------------+-------------+ -|+-+-+-+-+-+-+-+-+|+-+---+-+-+-+| -||a|b|c|d|e|f|g|h|||a|bcd|e|f|i|| -|+-+-+-+-+-+-+-+-+|+-+-+-+-+g+-+| -||i|jkl|m|nop|q|t|||j|m|nop|h|q|| -|+-+-+-+-+-+-+r+-+||k+-+-+-+-+r|| -||u|v|wxy|z|A|s|D|||l|t|w|xyz|s|| -|+-+-+-+-+-+B+-+-+|+-+u+-+-+-+-+| -||E|F|I|JKL|C|M|P|||A|v|B|E|FGH|| -|+-+G+-+---+-+N+-+|+-+-+C+-+-+-+| - -||Q|H|R|UVW|X|O|Y|||IJK|D|L|O|P|| -|+-+-+S+-+-+-+-+-+|+-+-+-+M+-+-+| -||Z|0|T|3|456|7|8|||Q|RST|N|U|V|| -|+-+1+-+-+-+-+-+-+|+-+---+-+-+-+| -||9|2|abc|d|efg|h|| | -|+-+-+-+-+-+-+-+-+| | -||i|j|k|l|m|n|o|p|| | -|+-+-+-+-+-+-+-+-+| | -+-----------------+-------------+ -]) -AT_CLEANUP AT_BANNER([output rendering -- double page breaks]) -- 2.30.2