- tab_box (t, TAL_1, TAL_1, -1, TAL_1, 0, 0, tab_nc (t) - 1, tab_nr (t) - 1);
- tab_hline (t, TAL_2, 0, 1, 1);
- tab_text (t, 0, 0, TAB_LEFT | TAT_TITLE, _("Attribute"));
- tab_text (t, 1, 0, TAB_LEFT | TAT_TITLE, _("Value"));
- display_attributes (t, set, flags, 0, 1);
- tab_title (t, "Custom data file attributes.");
- tab_submit (t);
-}
-
-/* Puts a description of variable V into table T starting at row
- R. The variable will be described in the format given by
- FLAGS. Returns the next row available for use in the
- table. */
-static int
-describe_variable (const struct variable *v, struct tab_table *t, int r,
- int pc, int flags)
-{
- size_t n_attrs = 0;
- int need_rows;
-
- /* Make sure that enough rows are allocated. */
- need_rows = 1;
- if (flags & ~(DF_DICT_INDEX | DF_VARIABLE_LABELS))
- need_rows += 16;
- if (flags & DF_VALUE_LABELS)
- need_rows += val_labs_count (var_get_value_labels (v));
- if (flags & (DF_ATTRIBUTES | DF_AT_ATTRIBUTES))
- {
- n_attrs = count_attributes (var_get_attributes (v), flags);
- need_rows += n_attrs;
- }
- if (r + need_rows > tab_nr (t))
- {
- int nr = MAX (r + need_rows, tab_nr (t) * 2);
- tab_realloc (t, -1, nr);
- }
-
- /* Put the name, var label, and position into the first row. */
- tab_text (t, 0, r, TAB_LEFT, var_get_name (v));
- if (flags & DF_DICT_INDEX)
- tab_text_format (t, pc, r, 0, "%zu", var_get_dict_index (v) + 1);
-
- if (flags & DF_VARIABLE_LABELS && var_has_label (v))
- {
- if (flags & ~(DF_DICT_INDEX | DF_VARIABLE_LABELS))
- tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
- _("Label: %s"), var_get_label (v));
- else
- tab_joint_text (t, 1, r, 2, r, TAB_LEFT, var_get_label (v));
- r++;
- }
-
- /* Print/write format, or print and write formats. */
- if (flags & DF_FORMATS)
- {
- const struct fmt_spec *print = var_get_print_format (v);
- const struct fmt_spec *write = var_get_write_format (v);
-
- if (fmt_equal (print, write))
- {
- char str[FMT_STRING_LEN_MAX + 1];
- tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
- _("Format: %s"), fmt_to_string (print, str));
- r++;
- }
- else
- {
- char str[FMT_STRING_LEN_MAX + 1];
- tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
- _("Print Format: %s"),
- fmt_to_string (print, str));
- r++;
- tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
- _("Write Format: %s"),
- fmt_to_string (write, str));
- r++;
- }
- }
-
- /* Measurement level, role, display width, alignment. */
- if (flags & DF_MISC)
- {
- enum var_role role = var_get_role (v);
-
- tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
- _("Measure: %s"),
- measure_to_string (var_get_measure (v)));
- r++;
-
- if (role != ROLE_INPUT)
- {
- tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
- _("Role: %s"), var_role_to_string (role));
- r++;
- }
-
- tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
- _("Display Alignment: %s"),
- alignment_to_string (var_get_alignment (v)));
- r++;
-
- tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
- _("Display Width: %d"),
- var_get_display_width (v));
- r++;
- }
-
- /* Missing values if any. */
- if (flags & DF_MISSING_VALUES && var_has_missing_values (v))
- {
- const struct missing_values *mv = var_get_missing_values (v);
- char buf[128];
- char *cp;
- int cnt = 0;
- int i;
-
- cp = stpcpy (buf, _("Missing Values: "));
-
- if (mv_has_range (mv))
- {
- double x, y;
- mv_get_range (mv, &x, &y);
- if (x == LOWEST)
- cp += sprintf (cp, "LOWEST THRU %.*g", DBL_DIG + 1, y);
- else if (y == HIGHEST)
- cp += sprintf (cp, "%.*g THRU HIGHEST", DBL_DIG + 1, x);
- else
- cp += sprintf (cp, "%.*g THRU %.*g",
- DBL_DIG + 1, x,
- DBL_DIG + 1, y);
- cnt++;
- }
- for (i = 0; i < mv_n_values (mv); i++)
- {
- const union value *value = mv_get_value (mv, i);
- if (cnt++ > 0)
- cp += sprintf (cp, "; ");
- if (var_is_numeric (v))
- cp += sprintf (cp, "%.*g", DBL_DIG + 1, value->f);
- else
- {
- int width = var_get_width (v);
- int mv_width = MIN (width, MV_MAX_STRING);
-
- *cp++ = '"';
- memcpy (cp, value_str (value, width), mv_width);
- cp += mv_width;
- *cp++ = '"';
- *cp = '\0';
- }
- }
-
- tab_joint_text (t, 1, r, 2, r, TAB_LEFT, buf);
- r++;
- }
-
- /* Value labels. */
- if (flags & DF_VALUE_LABELS && var_has_value_labels (v))
- {
- const struct val_labs *val_labs = var_get_value_labels (v);
- size_t n_labels = val_labs_count (val_labs);
- const struct val_lab **labels;
- int orig_r = r;
- size_t i;
-
-#if 0
- tab_text (t, 1, r, TAB_LEFT, _("Value"));
- tab_text (t, 2, r, TAB_LEFT, _("Label"));
- r++;
-#endif
-
- tab_hline (t, TAL_1, 1, 2, r);
-
- labels = val_labs_sorted (val_labs);
- for (i = 0; i < n_labels; i++)
- {
- const struct val_lab *vl = labels[i];
-
- tab_value (t, 1, r, TAB_NONE, &vl->value, v, NULL);
- tab_text (t, 2, r, TAB_LEFT, val_lab_get_escaped_label (vl));
- r++;
- }
- free (labels);
-
- tab_vline (t, TAL_1, 2, orig_r, r - 1);
- }
-
- if (flags & (DF_ATTRIBUTES | DF_AT_ATTRIBUTES) && n_attrs)
- {
- tab_joint_text (t, 1, r, 2, r, TAB_LEFT, "Custom attributes:");
- r++;
-
- display_attributes (t, var_get_attributes (v), flags, 1, r);
- r += n_attrs;
- }