-/* Searches VLS for a value label for VALUE. If successful,
- returns the label; otherwise, returns a null pointer. If
- VLS's width is greater than MAX_SHORT_STRING, always returns a
- null pointer. */
-char *
-val_labs_find (const struct val_labs *vls, union value value)
-{
- assert (vls != NULL);
-
- if (vls->width > MAX_SHORT_STRING)
- return NULL;
-
- if (vls->labels != NULL)
- {
- struct int_val_lab ivl, *vlp;
-
- ivl.value = value;
- vlp = hsh_find (vls->labels, &ivl);
- if (vlp != NULL)
- return atom_to_string (vlp->label);
- }
- return NULL;
-}
-\f
-/* A value labels iterator. */
-struct val_labs_iterator
- {
- void **labels; /* The labels, in order. */
- void **lp; /* Current label. */
- struct val_lab vl; /* Structure presented to caller. */
- };
-
-/* Sets up *IP for iterating through the value labels in VLS in
- no particular order. Returns the first value label or a null
- pointer if VLS is empty. If the return value is non-null,
- then val_labs_next() may be used to continue iterating or
- val_labs_done() to free up the iterator. Otherwise, neither
- function may be called for *IP. */
-struct val_lab *
-val_labs_first (const struct val_labs *vls, struct val_labs_iterator **ip)
-{
- struct val_labs_iterator *i;
-
- assert (vls != NULL);
- assert (ip != NULL);
-
- if (vls->labels == NULL || vls->width > MAX_SHORT_STRING)
- return NULL;
-
- i = *ip = xmalloc (sizeof *i);
- i->labels = hsh_data_copy (vls->labels);
- i->lp = i->labels;
- return val_labs_next (vls, ip);
-}
-
-/* Sets up *IP for iterating through the value labels in VLS in
- sorted order of values. Returns the first value label or a
- null pointer if VLS is empty. If the return value is
- non-null, then val_labs_next() may be used to continue
- iterating or val_labs_done() to free up the iterator.
- Otherwise, neither function may be called for *IP. */
-struct val_lab *
-val_labs_first_sorted (const struct val_labs *vls,
- struct val_labs_iterator **ip)
-{
- struct val_labs_iterator *i;
-
- assert (vls != NULL);
- assert (ip != NULL);
-
- if (vls->labels == NULL || vls->width > MAX_SHORT_STRING)
- return NULL;
-
- i = *ip = xmalloc (sizeof *i);
- i->lp = i->labels = hsh_sort_copy (vls->labels);
- return val_labs_next (vls, ip);
-}
-
-/* Returns the next value label in an iteration begun by
- val_labs_first() or val_labs_first_sorted(). If the return
- value is non-null, then val_labs_next() may be used to
- continue iterating or val_labs_done() to free up the iterator.
- Otherwise, neither function may be called for *IP. */
-struct val_lab *
-val_labs_next (const struct val_labs *vls, struct val_labs_iterator **ip)