+++ /dev/null
-/* 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 <http://www.gnu.org/licenses/>. */
-
-#include <config.h>
-
-#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 */
- };
#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;
}
table = tables[n_tables - 1];
- if (transpose)
- table = table_transpose (table);
table_item_submit (table_item_create (table, NULL, NULL));
free (tables);
}
{"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},
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|