- if (fmt_is_string (print->type)
- || dict_contains_var (dict, v))
- {
- data_out (case_data (c, v), print,
- ds_put_uninit (&line_buffer, print->w));
- }
- else
- {
- union value case_idx_value;
- case_idx_value.f = case_idx;
- data_out (&case_idx_value, print,
- ds_put_uninit (&line_buffer,print->w));
- }
-
- ds_put_char(&line_buffer, ' ');
- }
+ for (column = 0; column < cmd.n_variables; column++)
+ {
+ const struct variable *v = cmd.v_variables[column];
+ const struct fmt_spec *print = var_get_print_format (v);
+ int width;
+ char *s;
+
+ if (target->type == 0 && column >= target->n_vertical)
+ {
+ int name_len = strlen (var_get_name (v));
+ width = MAX (name_len, print->w);
+ }
+ else
+ width = print->w;
+
+ if (width + ds_length(&line_buffer) > max_width &&
+ ds_length(&line_buffer) != 0)
+ {
+ if (!n_lines_remaining (d))
+ {
+ outp_eject_page (d);
+ write_header (target);
+ }
+
+ write_line (d, ds_cstr (&line_buffer));
+ ds_clear(&line_buffer);
+
+ if (!target->header_rows)
+ ds_put_format (&line_buffer, "%8s: ", var_get_name (v));
+ }
+
+ if (width > print->w)
+ ds_put_char_multiple(&line_buffer, ' ', width - print->w);
+
+ if (fmt_is_string (print->type) || dict_contains_var (dict, v))
+ s = data_out (case_data (c, v), encoding, print);
+ else
+ {
+ union value case_idx_value;
+ case_idx_value.f = case_idx;
+ s = data_out (&case_idx_value, encoding, print);
+ }
+
+ ds_put_cstr (&line_buffer, s);
+ free (s);
+ ds_put_char(&line_buffer, ' ');
+ }