#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
+#include "algorithm.h"
#include "alloc.h"
-#include "avl.h"
#include "command.h"
#include "error.h"
#include "file-handle.h"
+#include "hash.h"
#include "lexer.h"
#include "misc.h"
#include "output.h"
#include "sfm.h"
#include "som.h"
#include "tab.h"
+#include "value-labels.h"
#include "var.h"
#include "vector.h"
tab_text (t, 1, 2, TAB_LEFT | TAT_PRINTF, "%s %s by %s",
inf.creation_date, inf.creation_time, inf.product);
tab_text (t, 0, 3, TAB_LEFT, _("Endian:"));
- tab_text (t, 1, 3, TAB_LEFT,
- (inf.endianness == BIG ? _("Big.")
- : (inf.endianness == LITTLE ? _("Little.")
- : (assert (0), _("<internal error>")))));
+ tab_text (t, 1, 3, TAB_LEFT, inf.bigendian ? _("Big.") : _("Little."));
tab_text (t, 0, 4, TAB_LEFT, _("Variables:"));
tab_text (t, 1, 4, TAB_LEFT | TAT_PRINTF, "%d",
d->nvar);
tab_hline (t, TAL_2, 0, 3, 1);
for (r = 1, i = 0; i < d->nvar; i++)
{
- int nvl = d->var[i]->val_lab ? avl_count (d->var[i]->val_lab) : 0;
+ int nvl = val_labs_count (d->var[i]->val_labs);
if (r + 10 + nvl > nr)
{
static void display_variables (struct variable **, int, int);
static void display_vectors (int sorted);
-static int cmp_var_by_name (const void *, const void *);
-
int
cmd_display (void)
{
}
if (sorted)
- qsort (vl, n, sizeof *vl, cmp_var_by_name);
+ sort (vl, n, sizeof *vl, compare_variables, NULL);
display_variables (vl, n, as);
return lex_end_of_command ();
}
-static int
-cmp_var_by_name (const void *a, const void *b)
-{
- return strcmp ((*((struct variable **) a))->name, (*((struct variable **) b))->name);
-}
-
static void
display_macros (void)
{
if (as == AS_DICTIONARY || as == AS_VARIABLES)
{
- int nvl = v->val_lab ? avl_count (v->val_lab) : 0;
+ int nvl = val_labs_count (v->val_labs);
if (r + 10 + nvl > nr)
{
}
/* Value labels. */
- if (as == AS_DICTIONARY && v->val_lab)
+ if (as == AS_DICTIONARY && val_labs_count (v->val_labs))
{
- avl_traverser trav;
- struct value_label *vl;
- int nvl = avl_count (v->val_lab);
+ struct val_labs_iterator *i;
+ struct val_lab *vl;
int orig_r = r;
- int i;
#if 0
tab_text (t, 1, r, TAB_LEFT, _("Value"));
#endif
tab_hline (t, TAL_1, 1, 2, r);
- avl_traverser_init (trav);
- for (i = 1, vl = avl_traverse (v->val_lab, &trav); vl;
- i++, vl = avl_traverse (v->val_lab, &trav))
- {
+ for (vl = val_labs_first_sorted (v->val_labs, &i); vl != NULL;
+ vl = val_labs_next (v->val_labs, &i))
+ {
char buf[128];
if (v->type == ALPHA)
{
- memcpy (buf, vl->v.s, v->width);
+ memcpy (buf, vl->value.s, v->width);
buf[v->width] = 0;
}
else
- sprintf (buf, "%g", vl->v.f);
+ sprintf (buf, "%g", vl->value.f);
tab_text (t, 1, r, TAB_NONE, buf);
- tab_text (t, 2, r, TAB_LEFT, vl->s);
+ tab_text (t, 2, r, TAB_LEFT, vl->label);
r++;
-
- if (i == nvl)
- break;
- }
-
- for (;;)
- {
- if (vl == NULL)
- break;
- vl = avl_traverse (v->val_lab, &trav);
}
tab_vline (t, TAL_1, 2, orig_r, r - 1);