/* Vertical lines inside the box */
tab_box (table, 0, 0, -1, TAL_1,
- 1, 0, table->nc - 1, tab_nr (table) - 1 );
+ 1, 0, tab_nc (table) - 1, tab_nr (table) - 1 );
/* Box around entire table */
tab_box (table, TAL_2, TAL_2, -1, -1,
- 0, 0, table->nc - 1, tab_nr (table) - 1 );
+ 0, 0, tab_nc (table) - 1, tab_nr (table) - 1 );
tab_text (table, 2, 0, TAB_CENTER, _("N"));
tab_text (table, 1, 3 + i * 4, TAB_LEFT, _("Ties"));
tab_text (table, 1, 4 + i * 4, TAB_LEFT, _("Total"));
- tab_hline (table, TAL_1, 0, table->nc - 1, 1 + i * 4);
+ tab_hline (table, TAL_1, 0, tab_nc (table) - 1, 1 + i * 4);
tab_text (table, 0, 1 + i * 4, TAB_LEFT, ds_cstr (&pair_name));
}
- tab_hline (table, TAL_2, 0, table->nc - 1, 1);
- tab_vline (table, TAL_2, 2, 0, table->nr - 1);
+ tab_hline (table, TAL_2, 0, tab_nc (table) - 1, 1);
+ tab_vline (table, TAL_2, 2, 0, tab_nr (table) - 1);
tab_submit (table);
/* Vertical lines inside the box */
tab_box (table, 0, 0, -1, TAL_1,
- 0, 0, table->nc - 1, tab_nr (table) - 1 );
+ 0, 0, tab_nc (table) - 1, tab_nr (table) - 1 );
/* Box around entire table */
tab_box (table, TAL_2, TAL_2, -1, -1,
- 0, 0, table->nc - 1, tab_nr (table) - 1 );
+ 0, 0, tab_nc (table) - 1, tab_nr (table) - 1 );
tab_text (table, 0, 1, TAB_LEFT, _("Z"));
}
}
- tab_hline (table, TAL_2, 0, table->nc - 1, 1);
- tab_vline (table, TAL_2, 1, 0, table->nr - 1);
+ tab_hline (table, TAL_2, 0, tab_nc (table) - 1, 1);
+ tab_vline (table, TAL_2, 1, 0, tab_nr (table) - 1);
tab_submit (table);
}
if (nr != -1)
{
- assert (nr + t->row_ofs <= t->nr);
+ assert (nr + t->row_ofs <= tab_nr (t));
t->nr = nr + t->row_ofs;
}
}
tab_offset (t, 0, 0);
if (nc == -1)
- nc = t->nc;
+ nc = tab_nc (t);
if (nr == -1)
- nr = t->nr;
+ nr = tab_nr (t);
- assert (nc == t->nc);
+ assert (nc == tab_nc (t));
if (nc > t->cf)
{
- int mr1 = MIN (nr, t->nr);
- int mc1 = MIN (nc, t->nc);
+ int mr1 = MIN (nr, tab_nr (t));
+ int mc1 = MIN (nc, tab_nc (t));
struct substring *new_cc;
unsigned char *new_ct;
new_ct = pool_malloc (t->container, nr * nc);
for (r = 0; r < mr1; r++)
{
- memcpy (&new_cc[r * nc], &t->cc[r * t->nc], mc1 * sizeof *t->cc);
- memcpy (&new_ct[r * nc], &t->ct[r * t->nc], mc1);
- memset (&new_ct[r * nc + t->nc], TAB_EMPTY, nc - t->nc);
+ memcpy (&new_cc[r * nc], &t->cc[r * tab_nc (t)], mc1 * sizeof *t->cc);
+ memcpy (&new_ct[r * nc], &t->ct[r * tab_nc (t)], mc1);
+ memset (&new_ct[r * nc + tab_nc (t)], TAB_EMPTY, nc - tab_nc (t));
}
pool_free (t->container, t->cc);
pool_free (t->container, t->ct);
t->ct = new_ct;
t->cf = nc;
}
- else if (nr != t->nr)
+ else if (nr != tab_nr (t))
{
t->cc = pool_nrealloc (t->container, t->cc, nr * nc, sizeof *t->cc);
t->ct = pool_realloc (t->container, t->ct, nr * nc);
t->rh = pool_nrealloc (t->container, t->rh, nc, nr + 1);
t->rv = pool_nrealloc (t->container, t->rv, nr, nc + 1);
- if (nr > t->nr)
+ if (nr > tab_nr (t))
{
- memset (&t->rh[nc * (t->nr + 1)], TAL_0, (nr - t->nr) * nc);
- memset (&t->rv[(nc + 1) * t->nr], UCHAR_MAX,
- (nr - t->nr) * (nc + 1));
+ memset (&t->rh[nc * (tab_nr (t) + 1)], TAL_0, (nr - tab_nr (t)) * nc);
+ memset (&t->rv[(nc + 1) * tab_nr (t)], UCHAR_MAX,
+ (nr - tab_nr (t)) * (nc + 1));
}
}
- memset (&t->ct[nc * t->nr], TAB_EMPTY, nc * (nr - t->nr));
+ memset (&t->ct[nc * tab_nr (t)], TAB_EMPTY, nc * (nr - tab_nr (t)));
t->nr = nr;
t->nc = nc;
assert (t != NULL);
#if DEBUGGING
- if (x + t->col_ofs < 0 || x + t->col_ofs > t->nc
- || y1 + t->row_ofs < 0 || y1 + t->row_ofs >= t->nr
- || y2 + t->row_ofs < 0 || y2 + t->row_ofs >= t->nr)
+ if (x + t->col_ofs < 0 || x + t->col_ofs > tab_nc (t)
+ || y1 + t->row_ofs < 0 || y1 + t->row_ofs >= tab_nr (t)
+ || y2 + t->row_ofs < 0 || y2 + t->row_ofs >= tab_nr (t))
{
printf (_("bad vline: x=%d+%d=%d y=(%d+%d=%d,%d+%d=%d) in "
"table size (%d,%d)\n"),
x, t->col_ofs, x + t->col_ofs,
y1, t->row_ofs, y1 + t->row_ofs,
y2, t->row_ofs, y2 + t->row_ofs,
- t->nc, t->nr);
+ tab_nc (t), tab_nr (t));
return;
}
#endif
y2 += t->row_ofs;
assert (x > 0);
- assert (x < t->nc);
+ assert (x < tab_nc (t));
assert (y1 >= 0);
assert (y2 >= y1);
- assert (y2 <= t->nr);
+ assert (y2 <= tab_nr (t));
if (style != -1)
{
y += t->row_ofs;
assert (y >= 0);
- assert (y <= t->nr);
+ assert (y <= tab_nr (t));
assert (x2 >= x1 );
assert (x1 >= 0 );
- assert (x2 < t->nc);
+ assert (x2 < tab_nc (t));
if (style != -1)
{
assert (t != NULL);
#if DEBUGGING
- if (x1 + t->col_ofs < 0 || x1 + t->col_ofs >= t->nc
- || x2 + t->col_ofs < 0 || x2 + t->col_ofs >= t->nc
- || y1 + t->row_ofs < 0 || y1 + t->row_ofs >= t->nr
- || y2 + t->row_ofs < 0 || y2 + t->row_ofs >= t->nr)
+ if (x1 + t->col_ofs < 0 || x1 + t->col_ofs >= tab_nc (t)
+ || x2 + t->col_ofs < 0 || x2 + t->col_ofs >= tab_nc (t)
+ || y1 + t->row_ofs < 0 || y1 + t->row_ofs >= tab_nr (t)
+ || y2 + t->row_ofs < 0 || y2 + t->row_ofs >= tab_nr (t))
{
printf (_("bad box: (%d+%d=%d,%d+%d=%d)-(%d+%d=%d,%d+%d=%d) "
"in table size (%d,%d)\n"),
y1, t->row_ofs, y1 + t->row_ofs,
x2, t->col_ofs, x2 + t->col_ofs,
y2, t->row_ofs, y2 + t->row_ofs,
- t->nc, t->nr);
+ tab_nc (t), tab_nr (t));
NOT_REACHED ();
}
#endif
assert (y2 >= y1);
assert (x1 >= 0);
assert (y1 >= 0);
- assert (x2 < t->nc);
- assert (y2 < t->nr);
+ assert (x2 < tab_nc (t));
+ assert (y2 < tab_nr (t));
if (f_h != -1)
{
const struct tab_table *t = r->table;
int width, row, max_width;
- assert (col >= 0 && col < t->nc);
+ assert (col >= 0 && col < tab_nc (t));
width = 0;
- for (row = 0; row < t->nr; row++)
+ for (row = 0; row < tab_nr (t); row++)
{
struct outp_text text;
unsigned char opt = t->ct[col + row * t->cf];
width = r->driver->prop_em_width * 8;
}
- max_width = r->driver->width - r->wrv[0] - r->wrv[t->nc];
+ max_width = r->driver->width - r->wrv[0] - r->wrv[tab_nc (t)];
return MIN (width, max_width);
}
const struct tab_table *t = r->table;
int height, col;
- assert (row >= 0 && row < t->nr);
+ assert (row >= 0 && row < tab_nr (t));
height = r->driver->font_height;
- for (col = 0; col < t->nc; col++)
+ for (col = 0; col < tab_nc (t); col++)
{
struct outp_text text;
unsigned char opt = t->ct[col + row * t->cf];
const struct tab_table *t = r->table;
int i;
- for (i = 0; i < t->nc; i++)
+ for (i = 0; i < tab_nc (t); i++)
r->w[i] = tab_natural_width (r, i);
- for (i = 0; i < t->nr; i++)
+ for (i = 0; i < tab_nr (t); i++)
r->h[i] = tab_natural_height (r, i);
}
assert (table != NULL && v != NULL && f != NULL);
#if DEBUGGING
if (c + table->col_ofs < 0 || r + table->row_ofs < 0
- || c + table->col_ofs >= table->nc
- || r + table->row_ofs >= table->nr)
+ || c + table->col_ofs >= tab_nc (table)
+ || r + table->row_ofs >= tab_nr (table))
{
printf ("tab_value(): bad cell (%d+%d=%d,%d+%d=%d) in table size "
"(%d,%d)\n",
c, table->col_ofs, c + table->col_ofs,
r, table->row_ofs, r + table->row_ofs,
- table->nc, table->nr);
+ tab_nc (table), tab_nr (table));
return;
}
#endif
assert (table != NULL && w <= 40);
assert (c >= 0);
- assert (c < table->nc);
+ assert (c < tab_nc (table));
assert (r >= 0);
- assert (r < table->nr);
+ assert (r < tab_nr (table));
f = fmt_for_output (FMT_F, w, d);
#if DEBUGGING
if (c + table->col_ofs < 0 || r + table->row_ofs < 0
- || c + table->col_ofs >= table->nc
- || r + table->row_ofs >= table->nr)
+ || c + table->col_ofs >= tab_nc (table)
+ || r + table->row_ofs >= tab_nr (table))
{
printf ("tab_fixed(): bad cell (%d+%d=%d,%d+%d=%d) in table size "
"(%d,%d)\n",
c, table->col_ofs, c + table->col_ofs,
r, table->row_ofs, r + table->row_ofs,
- table->nc, table->nr);
+ tab_nc (table), tab_nr (table));
return;
}
#endif
assert (table != NULL);
assert (c >= 0);
- assert (c < table->nc);
+ assert (c < tab_nc (table));
assert (r >= 0);
- assert (r < table->nr);
+ assert (r < tab_nr (table));
if ( fmt == NULL)
fmt = settings_get_format ();
#if DEBUGGING
if (c + table->col_ofs < 0 || r + table->row_ofs < 0
- || c + table->col_ofs >= table->nc
- || r + table->row_ofs >= table->nr)
+ || c + table->col_ofs >= tab_nc (table)
+ || r + table->row_ofs >= tab_nr (table))
{
printf ("tab_double(): bad cell (%d+%d=%d,%d+%d=%d) in table size "
"(%d,%d)\n",
c, table->col_ofs, c + table->col_ofs,
r, table->row_ofs, r + table->row_ofs,
- table->nc, table->nr);
+ tab_nc (table), tab_nr (table));
return;
}
#endif
assert (c >= 0 );
assert (r >= 0 );
- assert (c < table->nc);
- assert (r < table->nr);
+ assert (c < tab_nc (table));
+ assert (r < tab_nr (table));
#if DEBUGGING
if (c + table->col_ofs < 0 || r + table->row_ofs < 0
- || c + table->col_ofs >= table->nc
- || r + table->row_ofs >= table->nr)
+ || c + table->col_ofs >= tab_nc (table)
+ || r + table->row_ofs >= tab_nr (table))
{
printf ("tab_text(): bad cell (%d+%d=%d,%d+%d=%d) in table size "
"(%d,%d)\n",
c, table->col_ofs, c + table->col_ofs,
r, table->row_ofs, r + table->row_ofs,
- table->nc, table->nr);
+ tab_nc (table), tab_nr (table));
return;
}
#endif
assert (y1 + table->row_ofs >= 0);
assert (y2 >= y1);
assert (x2 >= x1);
- assert (y2 + table->row_ofs < table->nr);
- assert (x2 + table->col_ofs < table->nc);
+ assert (y2 + table->row_ofs < tab_nr (table));
+ assert (x2 + table->col_ofs < tab_nc (table));
#if DEBUGGING
- if (x1 + table->col_ofs < 0 || x1 + table->col_ofs >= table->nc
- || y1 + table->row_ofs < 0 || y1 + table->row_ofs >= table->nr
- || x2 < x1 || x2 + table->col_ofs >= table->nc
- || y2 < y2 || y2 + table->row_ofs >= table->nr)
+ if (x1 + table->col_ofs < 0 || x1 + table->col_ofs >= tab_nc (table)
+ || y1 + table->row_ofs < 0 || y1 + table->row_ofs >= tab_nr (table)
+ || x2 < x1 || x2 + table->col_ofs >= tab_nc (table)
+ || y2 < y2 || y2 + table->row_ofs >= tab_nr (table))
{
printf ("tab_joint_text(): bad cell "
"(%d+%d=%d,%d+%d=%d)-(%d+%d=%d,%d+%d=%d) in table size (%d,%d)\n",
y1, table->row_ofs, y1 + table->row_ofs,
x2, table->col_ofs, x2 + table->col_ofs,
y2, table->row_ofs, y2 + table->row_ofs,
- table->nc, table->nr);
+ tab_nc (table), tab_nr (table));
return;
}
#endif
#if DEBUGGING
if (c + table->col_ofs < 0 || r + table->row_ofs < 0
- || c + table->col_ofs >= table->nc
- || r + table->row_ofs >= table->nr)
+ || c + table->col_ofs >= tab_nc (table)
+ || r + table->row_ofs >= tab_nr (table))
{
printf ("tab_raw(): bad cell (%d+%d=%d,%d+%d=%d) in table size "
"(%d,%d)\n",
c, table->col_ofs, c + table->col_ofs,
r, table->row_ofs, r + table->row_ofs,
- table->nc, table->nr);
+ tab_nc (table), tab_nr (table));
return;
}
#endif
assert (t != NULL);
#if DEBUGGING
- if (row < -1 || row > t->nr)
+ if (row < -1 || row > tab_nr (t))
{
- printf ("tab_offset(): row=%d in %d-row table\n", row, t->nr);
+ printf ("tab_offset(): row=%d in %d-row table\n", row, tab_nr (t));
NOT_REACHED ();
}
- if (col < -1 || col > t->nc)
+ if (col < -1 || col > tab_nc (t))
{
- printf ("tab_offset(): col=%d in %d-column table\n", col, t->nc);
+ printf ("tab_offset(): col=%d in %d-column table\n", col, tab_nc (t));
NOT_REACHED ();
}
#endif
assert (t != NULL);
t->cc += t->cf;
t->ct += t->cf;
- if (++t->row_ofs >= t->nr)
- tab_realloc (t, -1, t->nr * 4 / 3);
+ if (++t->row_ofs >= tab_nr (t))
+ tab_realloc (t, -1, tab_nr (t) * 4 / 3);
}
\f
/* Return the number of columns and rows in the table into N_COLUMNS
r = xmalloc (sizeof *r);
r->table = t;
r->driver = driver;
- r->w = xnmalloc (t->nc, sizeof *r->w);
- r->h = xnmalloc (t->nr, sizeof *r->h);
- r->hrh = xnmalloc (t->nr + 1, sizeof *r->hrh);
- r->wrv = xnmalloc (t->nc + 1, sizeof *r->wrv);
+ r->w = xnmalloc (tab_nc (t), sizeof *r->w);
+ r->h = xnmalloc (tab_nr (t), sizeof *r->h);
+ r->hrh = xnmalloc (tab_nr (t) + 1, sizeof *r->hrh);
+ r->wrv = xnmalloc (tab_nc (t) + 1, sizeof *r->wrv);
r->l = hl;
r->r = hr;
r->t = ht;
r->b = hb;
/* Figure out sizes of rules. */
- for (row = 0; row <= t->nr; row++)
+ for (row = 0; row <= tab_nr (t); row++)
{
int width = 0;
- for (col = 0; col < t->nc; col++)
+ for (col = 0; col < tab_nc (t); col++)
{
unsigned char rh = t->rh[col + row * t->cf];
int w = driver->horiz_line_width[rule_to_spacing_type (rh)];
r->hrh[row] = width;
}
- for (col = 0; col <= t->nc; col++)
+ for (col = 0; col <= tab_nc (t); col++)
{
int width = 0;
- for (row = 0; row < t->nr; row++)
+ for (row = 0; row < tab_nr (t); row++)
{
unsigned char *rv = &t->rv[col + row * (t->cf + 1)];
int w;
if (*rv == UCHAR_MAX)
- *rv = col != 0 && col != t->nc ? TAL_GAP : TAL_0;
+ *rv = col != 0 && col != tab_nc (t) ? TAL_GAP : TAL_0;
w = driver->vert_line_width[rule_to_spacing_type (*rv)];
if (w > width)
width = w;
}
/* Determine row heights and columns widths. */
- for (i = 0; i < t->nr; i++)
+ for (i = 0; i < tab_nr (t); i++)
r->h[i] = -1;
- for (i = 0; i < t->nc; i++)
+ for (i = 0; i < tab_nc (t); i++)
r->w[i] = -1;
t->dim (r, t->dim_aux);
- for (i = 0; i < t->nr; i++)
+ for (i = 0; i < tab_nr (t); i++)
if (r->h[i] < 0)
error (0, 0, "height of table row %d is %d (not initialized?)",
i, r->h[i]);
- for (i = 0; i < t->nc; i++)
+ for (i = 0; i < tab_nc (t); i++)
if (r->w[i] < 0)
error (0, 0, "width of table column %d is %d (not initialized?)",
i, r->w[i]);
r->wl += r->w[i] + r->wrv[i + 1];
for (i = 0, r->ht = r->hrh[0]; i < r->t; i++)
r->ht += r->h[i] + r->hrh[i + 1];
- for (i = t->nc - r->r, r->wr = r->wrv[i]; i < t->nc; i++)
+ for (i = tab_nc (t) - r->r, r->wr = r->wrv[i]; i < tab_nc (t); i++)
r->wr += r->w[i] + r->wrv[i + 1];
- for (i = t->nr - r->b, r->hb = r->hrh[i]; i < t->nr; i++)
+ for (i = tab_nr (t) - r->b, r->hb = r->hrh[i]; i < tab_nr (t); i++)
r->hb += r->h[i] + r->hrh[i + 1];
/* Title. */
int height, row;
width = 0;
- for (col = r->l + 1, width = r->wl + r->wr + r->w[t->l];
- col < t->nc - r->r; col++)
+ for (col = r->l + 1, width = r->wl + r->wr + r->w[tab_l (t)];
+ col < tab_nc (t) - r->r; col++)
width += r->w[col] + r->wrv[col];
*horiz = width;
height = 0;
- for (row = r->t + 1, height = r->ht + r->hb + r->h[t->t];
- row < t->nr - t->b; row++)
+ for (row = r->t + 1, height = r->ht + r->hb + r->h[tab_t (t)];
+ row < tab_nr (t) - tab_b (t); row++)
height += r->h[row] + r->hrh[row];
*vert = height;
}
assert (end != NULL && (cumtype == SOM_ROWS || cumtype == SOM_COLUMNS));
if (cumtype == SOM_ROWS)
{
- assert (start >= 0 && start < t->nr);
- limit = t->nr - r->b;
+ assert (start >= 0 && start < tab_nr (t));
+ limit = tab_nr (t) - r->b;
cells = &r->h[start];
rules = &r->hrh[start + 1];
total = r->ht + r->hb;
}
else
{
- assert (start >= 0 && start < t->nc);
- limit = t->nc - t->r;
+ assert (start >= 0 && start < tab_nc (t));
+ limit = tab_nc (t) - tab_r (t);
cells = &r->w[start];
rules = &r->wrv[start + 1];
total = r->wl + r->wr;
/* Rows to render, counting horizontal rules as rows. */
n_row_ranges = 0;
- add_range (rows, &n_row_ranges, 0, t->t * 2 + 1);
+ add_range (rows, &n_row_ranges, 0, tab_t (t) * 2 + 1);
add_range (rows, &n_row_ranges, r0 * 2 + 1, r1 * 2);
- add_range (rows, &n_row_ranges, (t->nr - t->b) * 2, t->nr * 2 + 1);
+ add_range (rows, &n_row_ranges, (tab_nr (t) - tab_b (t)) * 2,
+ tab_nr (t) * 2 + 1);
/* Columns to render, counting vertical rules as columns. */
n_col_ranges = 0;
add_range (cols, &n_col_ranges, 0, r->l * 2 + 1);
add_range (cols, &n_col_ranges, c0 * 2 + 1, c1 * 2);
- add_range (cols, &n_col_ranges, (t->nc - r->r) * 2, t->nc * 2 + 1);
+ add_range (cols, &n_col_ranges, (tab_nc (t) - r->r) * 2, tab_nc (t) * 2 + 1);
y = r->driver->cp_y;
if (!(t->flags & SOMF_NO_TITLE))
/* Lines on each side of intersection. */
int top = row > 0 ? get_vrule (t, col, row - 1) : TAL_0;
int left = col > 0 ? get_hrule (t, col - 1, row) : TAL_0;
- int bottom = row < t->nr ? get_vrule (t, col, row) : TAL_0;
- int right = col < t->nc ? get_hrule (t, col, row) : TAL_0;
+ int bottom = row < tab_nr (t) ? get_vrule (t, col, row) : TAL_0;
+ int right = col < tab_nc (t) ? get_hrule (t, col, row) : TAL_0;
/* Output style for each line. */
enum outp_line_style o_top = rule_to_draw_type (top);