From 4b21e521f63472b15ac1fa97a148feb4306442a5 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 22 Jan 2019 20:27:44 -0800 Subject: [PATCH] table-transpose: Remove. This had only only user, which this commit also removes. --- src/output/automake.mk | 1 - src/output/table-transpose.c | 119 ----------------------------------- src/output/table.h | 3 - tests/output/render-test.c | 6 -- tests/output/render.at | 47 ++++++++++++-- 5 files changed, 41 insertions(+), 135 deletions(-) delete mode 100644 src/output/table-transpose.c diff --git a/src/output/automake.mk b/src/output/automake.mk index 636e9a7980..4593ea1172 100644 --- a/src/output/automake.mk +++ b/src/output/automake.mk @@ -79,7 +79,6 @@ src_output_liboutput_la_SOURCES = \ src/output/table-paste.c \ src/output/table-provider.h \ src/output/table-select.c \ - src/output/table-transpose.c \ src/output/table.c \ src/output/table.h \ src/output/text-item.c \ diff --git a/src/output/table-transpose.c b/src/output/table-transpose.c deleted file mode 100644 index aa617b3aaa..0000000000 --- a/src/output/table-transpose.c +++ /dev/null @@ -1,119 +0,0 @@ -/* PSPP - a program for statistical analysis. - Copyright (C) 2009, 2011 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 - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -#include "libpspp/assertion.h" -#include "libpspp/cast.h" -#include "output/table-provider.h" - -#include "gl/minmax.h" -#include "gl/xalloc.h" - -struct table_transpose - { - struct table table; - struct table *subtable; - }; - -static const struct table_class table_transpose_class; - -static struct table_transpose * -table_transpose_cast (const struct table *table) -{ - assert (table->klass == &table_transpose_class); - return UP_CAST (table, struct table_transpose, table); -} - -/* Takes ownership of SUBTABLE and returns a new table whose contents are - SUBTABLE with rows and columns transposed. */ -struct table * -table_transpose (struct table *subtable) -{ - if (subtable->n[TABLE_HORZ] == subtable->n[TABLE_VERT] - && subtable->n[TABLE_HORZ] <= 1) - return subtable; - else if (subtable->klass == &table_transpose_class) - { - struct table_transpose *tt = table_transpose_cast (subtable); - struct table *table = table_ref (tt->subtable); - table_unref (subtable); - return table; - } - else - { - struct table_transpose *tt; - int axis; - - tt = xmalloc (sizeof *tt); - table_init (&tt->table, &table_transpose_class); - tt->subtable = subtable; - - for (axis = 0; axis < TABLE_N_AXES; axis++) - { - tt->table.n[axis] = subtable->n[!axis]; - tt->table.h[axis][0] = subtable->h[!axis][0]; - tt->table.h[axis][1] = subtable->h[!axis][1]; - } - return &tt->table; - } -} - -static void -table_transpose_destroy (struct table *ti) -{ - struct table_transpose *tt = table_transpose_cast (ti); - table_unref (tt->subtable); - free (tt); -} - -static void -swap (int *x, int *y) -{ - int t = *x; - *x = *y; - *y = t; -} - -static void -table_transpose_get_cell (const struct table *ti, int x, int y, - struct table_cell *cell) -{ - struct table_transpose *tt = table_transpose_cast (ti); - int i; - - table_get_cell (tt->subtable, y, x, cell); - for (i = 0; i < 2; i++) - swap (&cell->d[TABLE_HORZ][i], &cell->d[TABLE_VERT][i]); -} - -static int -table_transpose_get_rule (const struct table *ti, - enum table_axis axis, - int x, int y, struct cell_color *color) -{ - struct table_transpose *tt = table_transpose_cast (ti); - return table_get_rule (tt->subtable, !axis, y, x, color); -} - -static const struct table_class table_transpose_class = - { - table_transpose_destroy, - table_transpose_get_cell, - table_transpose_get_rule, - NULL, /* paste */ - NULL, /* select */ - }; diff --git a/src/output/table.h b/src/output/table.h index 40cae3a22c..54995600cb 100644 --- a/src/output/table.h +++ b/src/output/table.h @@ -286,7 +286,4 @@ struct table *table_select_columns (struct table *, struct table *table_select_rows (struct table *, int y0, int y1, bool add_headers); -/* Miscellaneous table operations. */ -struct table *table_transpose (struct table *); - #endif /* output/table.h */ diff --git a/tests/output/render-test.c b/tests/output/render-test.c index 421b9be066..4c559a53d9 100644 --- a/tests/output/render-test.c +++ b/tests/output/render-test.c @@ -36,9 +36,6 @@ #include "gl/xalloc.h" #include "gl/xvasprintf.h" -/* --transpose: Transpose the table before outputting? */ -static int transpose; - /* --emphasis: ASCII driver emphasis option. */ static bool bold; static bool underline; @@ -115,8 +112,6 @@ main (int argc, char **argv) } table = tables[n_tables - 1]; - if (transpose) - table = table_transpose (table); table_item_submit (table_item_create (table, NULL, NULL)); free (tables); } @@ -252,7 +247,6 @@ parse_options (int argc, char **argv) {"width", required_argument, NULL, OPT_WIDTH}, {"length", required_argument, NULL, OPT_LENGTH}, {"min-break", required_argument, NULL, OPT_MIN_BREAK}, - {"transpose", no_argument, &transpose, 1}, {"emphasis", required_argument, NULL, OPT_EMPHASIS}, {"box", required_argument, NULL, OPT_BOX}, {"draw-mode", no_argument, &draw_mode, 1}, diff --git a/tests/output/render.at b/tests/output/render.at index bc23280639..e54025560d 100644 --- a/tests/output/render.at +++ b/tests/output/render.at @@ -314,13 +314,48 @@ AT_CLEANUP AT_SETUP([3 columns with many joined cells]) AT_KEYWORDS([render rendering]) AT_CAPTURE_FILE([input]) -AT_DATA([input], [3 19 -m4_foreach([x], [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s], [x -])@1 -m4_for([x], [2], [19], [1], [1*2 @x\nab\ncd -])@20 +AT_DATA([input], [19 3 +a +@1 +2*1 @11\nab\ncd +b +2*1 @2\nab\ncd +c +2*1 @12\nab\ncd +d +2*1 @3\nab\ncd +e +2*1 @13\nab\ncd +f +2*1 @4\nab\ncd +g +2*1 @14\nab\ncd +h +2*1 @5\nab\ncd +i +2*1 @15\nab\ncd +j +2*1 @6\nab\ncd +k +2*1 @16\nab\ncd +l +2*1 @7\nab\ncd +m +2*1 @17\nab\ncd +n +2*1 @8\nab\ncd +o +2*1 @18\nab\ncd +p +2*1 @9\nab\ncd +q +2*1 @19\nab\ncd +r +2*1 @10\nab\ncd +s +@20 ]) -AT_CHECK([render-test --transpose input], [0], [dnl +AT_CHECK([render-test input], [0], [dnl +--+--+ a| 1|11| +--+ab| -- 2.30.2