struct tab_table *table, int c, int r, unsigned char opt,
const union value *v, const struct variable *var)
{
- struct substring s;
- const struct fmt_spec *print = var_get_print_format (var);
-
const char *label = var_lookup_value_label (var, v);
- if (label)
- {
- tab_text (table, c, r, TAB_LEFT, label);
- return;
- }
-
- s.string = tab_alloc (table, print->w);
- data_out (v, print, s.string);
- s.length = print->w;
- if (proc->exclude == MV_NEVER && var_is_num_missing (var, v->f, MV_USER))
- s.string[s.length++] = 'M';
- while (s.length && *s.string == ' ')
+ if (label != NULL)
+ tab_text (table, c, r, TAB_LEFT, label);
+ else
{
- s.length--;
- s.string++;
+ const struct fmt_spec *print = var_get_print_format (var);
+ if (proc->exclude == MV_NEVER && var_is_value_missing (var, v, MV_USER))
+ {
+ char *s = xmalloc (print->w + 2);
+ strcpy (&s[print->w], "M");
+ tab_text (table, c, r, opt, s + strspn (s, " "));
+ free (s);
+ }
+ else
+ tab_value (table, c, r, opt, v, print);
}
- tab_raw (table, c, r, opt, &s);
}
/* Draws a line across TABLE at the current row to indicate the most
{
const struct fmt_spec f = {FMT_F, 10, 1};
union value v;
- struct substring s;
+ int len = 10;
+ char s[16];
- s.length = 10;
- s.string = tab_alloc (table, 16);
v.f = value;
- data_out (&v, &f, s.string);
- while (*s.string == ' ')
- {
- s.length--;
- s.string++;
- }
+ data_out (&v, &f, s);
if (suffix != 0)
- s.string[s.length++] = suffix;
+ s[len++] = suffix;
if (mark_missing)
- s.string[s.length++] = 'M';
+ s[len++] = 'M';
+ s[len] = '\0';
- tab_raw (table, c, r, TAB_RIGHT, &s);
+ tab_text (table, c, r, TAB_RIGHT, s + strspn (s, " "));
}
/* Displays the crosstabulation table. */
pool_vasprintf (table->container, format, args));
va_end (args);
}
-
-/* Sets cell (C,R) in TABLE, with options OPT, to contents STRING. */
-void
-tab_raw (struct tab_table *table, int c, int r, unsigned opt,
- struct substring *string)
-{
- assert (table != NULL && string != NULL);
-
-#if DEBUGGING
- if (c + table->col_ofs < 0 || r + table->row_ofs < 0
- || 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,
- tab_nc (table), tab_nr (table));
- return;
- }
-#endif
-
- table->cc[c + r * table->cf] = *string;
- table->ct[c + r * table->cf] = opt;
-}
\f
/* Miscellaneous. */
unsigned opt, const char *, ...)
PRINTF_FORMAT (7, 8);
-/* Cell low-level access. */
-#define tab_alloc(TABLE, AMT) pool_alloc ((TABLE)->container, (AMT))
-void tab_raw (struct tab_table *, int c, int r, unsigned opt,
- struct substring *);
-
/* Editing. */
void tab_offset (struct tab_table *, int col, int row);
void tab_next_row (struct tab_table *);