c->margin[TABLE_VERT][0], c->margin[TABLE_VERT][1]);
}
\f
-
-static const bool debugging = true;
-
/* Creates and returns a new table with NC columns and NR rows and initially no
header rows or columns.
Sets the number of header rows on each side of TABLE to HL on the
- left, HR on the right, HT on the top, HB on the bottom. Header rows
+ left, HT on the top. Header rows
are repeated when a table is broken across multiple columns or
multiple pages.
The table's cells are initially empty. */
struct table *
-table_create (int nc, int nr, int hl, int hr, int ht, int hb)
+table_create (int nc, int nr, int hl, int ht)
{
struct pool *pool = pool_create ();
struct table *t = pool_alloc (pool, sizeof *t);
*t = (struct table) {
.container = pool,
.n = { [H] = nc, [V] = nr },
- .h = { [H] = { hl, hr }, [V] = { ht, hb } },
+ .h = { [H] = hl, [V] = ht },
.ref_cnt = 1,
.cc = pool_calloc (pool, nr * nc, sizeof *t->cc),
.cp = pool_calloc (pool, nr * nc, sizeof *t->cp),
.rh = pool_calloc (pool, nc, nr + 1),
- .rv = pool_nmalloc (pool, nr, nc + 1),
+ .rv = pool_calloc (pool, nr, nc + 1),
};
return t;
}
void
table_vline (struct table *t, int style, int x, int y1, int y2)
{
- if (debugging)
+ if (x < 0 || x > t->n[H] || y1 < 0 || y1 > y2 || y2 >= t->n[V])
{
- if (x < 0 || x > t->n[H]
- || y1 < 0 || y1 >= t->n[V]
- || y2 < 0 || y2 >= t->n[V])
- {
- printf ("bad vline: x=%d y=(%d,%d) in table size (%d,%d)\n",
- x, y1, y2, t->n[H], t->n[V]);
- return;
- }
+ printf ("bad vline: x=%d y=(%d,%d) in table size (%d,%d)\n",
+ x, y1, y2, t->n[H], t->n[V]);
+ abort ();
}
- assert (0 <= x && x <= t->n[H]);
- assert (0 <= y1 && y1 <= y2 && y2 <= t->n[V]);
-
for (int y = y1; y <= y2; y++)
t->rv[x + (t->n[H] + 1) * y] = style;
}
void
table_hline (struct table *t, int style, int x1, int x2, int y)
{
- if (debugging)
+ if (y < 0 || y > t->n[V] || x1 < 0 || x1 > x2 || x2 >= t->n[H])
{
- if (y < 0 || y > t->n[V]
- || x1 < 0 || x1 >= t->n[H]
- || x2 < 0 || x2 >= t->n[H])
- {
- printf ("bad hline: x=(%d,%d) y=%d in table size (%d,%d)\n",
- x1, x2, y, t->n[H], t->n[V]);
- return;
- }
+ printf ("bad hline: x=(%d,%d) y=%d in table size (%d,%d)\n",
+ x1, x2, y, t->n[H], t->n[V]);
+ abort ();
}
- assert (0 <= y && y <= t->n[V]);
- assert (0 <= x1 && x1 <= x2 && x2 < t->n[H]);
-
for (int x = x1; x <= x2; x++)
t->rh[x + t->n[H] * y] = style;
}
assert (0 <= x1 && x1 <= x2 && x2 < table->n[H]);
assert (0 <= y1 && y1 <= y2 && y2 < table->n[V]);
+ const bool debugging = false;
+ if (debugging)
+ {
+ printf ("put ");
+ if (x1 == x2)
+ printf ("%d", x1);
+ else
+ printf ("%d-%d", x1, x2);
+ printf (",");
+ if (y1 == y2)
+ printf ("%d", y1);
+ else
+ printf ("%d-%d", y1, y2);
+
+ char *value_s = value ? pivot_value_to_string (value, NULL) : NULL;
+ printf (": \"%s\"\n", value_s ? value_s : "");
+ free (value_s);
+ }
+
if (x1 == x2 && y1 == y2)
{
table->cc[x1 + y1 * table->n[H]] = CONST_CAST (struct pivot_value *, value);