/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2009 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
/* Set DIM_FUNC as the dimension function for table T. */
void
-tab_dim (struct tab_table *t, tab_dim_func *dim_func)
+tab_dim (struct tab_table *t, tab_dim_func *dim_func, void *aux)
{
assert (t != NULL && t->dim == NULL);
t->dim = dim_func;
+ t->dim_aux = aux;
}
/* Returns the natural width of column C in table T for driver D, that
/* Callback function to set all columns and rows to their natural
dimensions. Not really meant to be called directly. */
void
-tab_natural_dimensions (struct tab_table *t, struct outp_driver *d)
+tab_natural_dimensions (struct tab_table *t, struct outp_driver *d,
+ void *aux UNUSED)
{
int i;
}
#endif
- contents = pool_alloc (table->container, f->w);
- table->cc[c + r * table->cf] = ss_buffer (contents, f->w);
- table->ct[c + r * table->cf] = opt;
+ contents = data_out_pool (v, "FIXME", f, table->container);
- data_out (v, f, contents);
+ table->cc[c + r * table->cf] = ss_cstr (contents);
+ table->ct[c + r * table->cf] = opt;
}
/* Sets cell (C,R) in TABLE, with options OPT, to have value VAL
tab_fixed (struct tab_table *table, int c, int r, unsigned char opt,
double val, int w, int d)
{
- char *contents;
- char buf[40], *cp;
+ char *s, *cp;
struct fmt_spec f;
union value double_value;
#endif
double_value.f = val;
- data_out (&double_value, &f, buf);
+ s = data_out_pool (&double_value, "FIXME", &f, table->container);
- cp = buf;
- while (isspace ((unsigned char) *cp) && cp < &buf[w])
+ cp = s;
+ while (isspace ((unsigned char) *cp) && cp < &s[w])
cp++;
- f.w = w - (cp - buf);
+ f.w = w - (cp - s);
- contents = pool_alloc (table->container, f.w);
- table->cc[c + r * table->cf] = ss_buffer (contents, f.w);
+ table->cc[c + r * table->cf] = ss_buffer (cp, f.w);
table->ct[c + r * table->cf] = opt;
- memcpy (contents, cp, f.w);
}
/* Sets cell (C,R) in TABLE, with options OPT, to have value VAL as
double val, const struct fmt_spec *fmt)
{
int w;
- char *contents;
- char buf[40], *cp;
+ char *s, *cp;
- union value double_value;
+ union value double_value ;
assert (table != NULL);
#endif
double_value.f = val;
- data_out (&double_value, fmt, buf);
+ s = data_out_pool (&double_value, "FIXME", fmt, table->container);
- cp = buf;
- while (isspace ((unsigned char) *cp) && cp < &buf[fmt->w])
- cp++;
- w = fmt->w - (cp - buf);
-
- contents = pool_alloc (table->container, w);
- table->cc[c + r * table->cf] = ss_buffer (contents, w);
+ cp = s;
+ while (isspace ((unsigned char) *cp) && cp < s + fmt->w)
+ {
+ cp++;
+ }
+ w = fmt->w - (cp - s);
+
+ table->cc[c + r * table->cf] = ss_buffer (cp, w);
table->ct[c + r * table->cf] = opt;
- memcpy (contents, cp, w);
}
/* Sets the widths of all the columns and heights of all the rows in
table T for driver D. */
static void
-nowrap_dim (struct tab_table *t, struct outp_driver *d)
+nowrap_dim (struct tab_table *t, struct outp_driver *d, void *aux UNUSED)
{
t->w[0] = tab_natural_width (t, d, 0);
t->h[0] = d->font_height;
/* Sets the widths of all the columns and heights of all the rows in
table T for driver D. */
static void
-wrap_dim (struct tab_table *t, struct outp_driver *d)
+wrap_dim (struct tab_table *t, struct outp_driver *d, void *aux UNUSED)
{
t->w[0] = tab_natural_width (t, d, 0);
t->h[0] = tab_natural_height (t, d, 0);
tab_text (t, 0, 0, options & ~TAT_PRINTF, buf);
tab_flags (t, SOMF_NO_TITLE | SOMF_NO_SPACING);
- tab_dim (t, options & TAT_NOWRAP ? nowrap_dim : wrap_dim);
+ tab_dim (t, options & TAT_NOWRAP ? nowrap_dim : wrap_dim, NULL);
tab_submit (t);
free (tmp_buf);
#endif
assert (t->dim != NULL);
- t->dim (t, d);
+ t->dim (t, d, t->dim_aux);
#if DEBUGGING
{