#include <output/output.h>
#include <output/table.h>
+#include "minmax.h"
+
#include "gettext.h"
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
const struct freq *value = value_;
struct variable *v = v_;
- return hsh_hash_bytes (value->v.s, v->width);
+ return hsh_hash_bytes (value->v.s, MIN (MAX_SHORT_STRING, v->width));
}
/* Ascending numeric compare of values. */
const struct freq *b = b_;
const struct variable *v = v_;
- return memcmp (a->v.s, b->v.s, v->width);
+ return memcmp (a->v.s, b->v.s, MIN (MAX_SHORT_STRING, v->width));
}
/* Descending numeric compare of values. */
else if (a->c < b->c)
return -1;
else
- return memcmp (a->v.s, b->v.s, v->width);
+ return memcmp (a->v.s, b->v.s, MIN (MAX_SHORT_STRING, v->width));
}
/* Descending numeric compare of frequency;
else if (a->c < b->c)
return 1;
else
- return memcmp (a->v.s, b->v.s, v->width);
+ return memcmp (a->v.s, b->v.s, MIN (MAX_SHORT_STRING, v->width));
}
\f
/* Frequency table display. */
int r;
double cum_total = 0.0;
double cum_freq = 0.0;
+ struct fmt_spec fmt;
struct init
{
tab_text (t, p->c - (p->r ? !lab : 0), p->r,
TAB_CENTER | TAT_TITLE, gettext (p->s));
+ fmt = v->print;
+ if (v->width > MAX_SHORT_STRING)
+ fmt.w = MAX_SHORT_STRING * (fmt.type == FMT_AHEX ? 2 : 1);
+
r = 2;
for (f = ft->valid; f < ft->missing; f++)
{
tab_text (t, 0, r, TAB_LEFT, label);
}
- tab_value (t, 0 + lab, r, TAB_NONE, &f->v, &v->print);
+ tab_value (t, 0 + lab, r, TAB_NONE, &f->v, &fmt);
tab_float (t, 1 + lab, r, TAB_NONE, f->c, 8, 0);
tab_float (t, 2 + lab, r, TAB_NONE, percent, 5, 1);
tab_float (t, 3 + lab, r, TAB_NONE, valid_percent, 5, 1);
tab_text (t, 0, r, TAB_LEFT, label);
}
- tab_value (t, 0 + lab, r, TAB_NONE, &f->v, &v->print);
+ tab_value (t, 0 + lab, r, TAB_NONE, &f->v, &fmt);
tab_float (t, 1 + lab, r, TAB_NONE, f->c, 8, 0);
tab_float (t, 2 + lab, r, TAB_NONE,
f->c / ft->total_cases * 100.0, 5, 1);
struct tab_table *t;
int r;
double cum_total = 0.0;
+ struct fmt_spec fmt;
ft = &get_var_freqs (v)->tab;
n_categories = ft->n_valid + ft->n_missing;
tab_text (t, 3, 1, TAB_CENTER | TAT_TITLE, _("Pct"));
tab_dim (t, condensed_dim);
+ fmt = v->print;
+ if (v->width > MAX_SHORT_STRING)
+ fmt.w = MAX_SHORT_STRING * (fmt.type == FMT_AHEX ? 2 : 1);
+
r = 2;
for (f = ft->valid; f < ft->missing; f++)
{
percent = f->c / ft->total_cases * 100.0;
cum_total += f->c / ft->valid_cases * 100.0;
- tab_value (t, 0, r, TAB_NONE, &f->v, &v->print);
+ tab_value (t, 0, r, TAB_NONE, &f->v, &fmt);
tab_float (t, 1, r, TAB_NONE, f->c, 8, 0);
tab_float (t, 2, r, TAB_NONE, percent, 3, 0);
tab_float (t, 3, r, TAB_NONE, cum_total, 3, 0);
}
for (; f < &ft->valid[n_categories]; f++)
{
- tab_value (t, 0, r, TAB_NONE, &f->v, &v->print);
+ tab_value (t, 0, r, TAB_NONE, &f->v, &fmt);
tab_float (t, 1, r, TAB_NONE, f->c, 8, 0);
tab_float (t, 2, r, TAB_NONE,
f->c / ft->total_cases * 100.0, 3, 0);