Update code that assumed a dictionary's encoding could be NULL.
[pspp] / src / language / dictionary / sys-file-info.c
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 #include <config.h>
18
19 #include <ctype.h>
20 #include <stdlib.h>
21
22 #include "data/attributes.h"
23 #include "data/casereader.h"
24 #include "data/dataset.h"
25 #include "data/dictionary.h"
26 #include "data/file-handle-def.h"
27 #include "data/format.h"
28 #include "data/missing-values.h"
29 #include "data/sys-file-reader.h"
30 #include "data/value-labels.h"
31 #include "data/variable.h"
32 #include "data/vector.h"
33 #include "language/command.h"
34 #include "language/data-io/file-handle.h"
35 #include "language/lexer/lexer.h"
36 #include "language/lexer/variable-parser.h"
37 #include "libpspp/array.h"
38 #include "libpspp/message.h"
39 #include "libpspp/misc.h"
40 #include "libpspp/string-array.h"
41 #include "output/tab.h"
42
43 #include "gl/minmax.h"
44 #include "gl/xalloc.h"
45
46 #include "gettext.h"
47 #define _(msgid) gettext (msgid)
48
49 /* Information to include in displaying a dictionary. */
50 enum 
51   {
52     DF_DICT_INDEX       = 1 << 0,
53     DF_FORMATS          = 1 << 1,
54     DF_VALUE_LABELS     = 1 << 2,
55     DF_VARIABLE_LABELS  = 1 << 3,
56     DF_MISSING_VALUES   = 1 << 4,
57     DF_AT_ATTRIBUTES    = 1 << 5, /* Attributes whose names begin with @. */
58     DF_ATTRIBUTES       = 1 << 6, /* All other attributes. */
59     DF_MISC             = 1 << 7,
60     DF_ALL              = (1 << 8) - 1
61   };
62
63 static int describe_variable (const struct variable *v, struct tab_table *t,
64                               int r, int pc, int flags);
65
66 /* SYSFILE INFO utility. */
67 int
68 cmd_sysfile_info (struct lexer *lexer, struct dataset *ds UNUSED)
69 {
70   struct file_handle *h;
71   struct dictionary *d;
72   struct tab_table *t;
73   struct casereader *reader;
74   struct sfm_read_info info;
75   int r, i;
76
77   lex_match_id (lexer, "FILE");
78   lex_match (lexer, T_EQUALS);
79
80   h = fh_parse (lexer, FH_REF_FILE, NULL);
81   if (!h)
82     return CMD_FAILURE;
83
84   reader = sfm_open_reader (h, &d, &info);
85   if (!reader)
86     {
87       fh_unref (h);
88       return CMD_FAILURE;
89     }
90   casereader_destroy (reader);
91
92   t = tab_create (2, 11);
93   tab_vline (t, TAL_GAP, 1, 0, 8);
94   tab_text (t, 0, 0, TAB_LEFT, _("File:"));
95   tab_text (t, 1, 0, TAB_LEFT, fh_get_file_name (h));
96   tab_text (t, 0, 1, TAB_LEFT, _("Label:"));
97   {
98     const char *label = dict_get_label (d);
99     if (label == NULL)
100       label = _("No label.");
101     tab_text (t, 1, 1, TAB_LEFT, label);
102   }
103   tab_text (t, 0, 2, TAB_LEFT, _("Created:"));
104   tab_text_format (t, 1, 2, TAB_LEFT, "%s %s by %s",
105                    info.creation_date, info.creation_time, info.product);
106   tab_text (t, 0, 3, TAB_LEFT, _("Integer Format:"));
107   tab_text (t, 1, 3, TAB_LEFT,
108             info.integer_format == INTEGER_MSB_FIRST ? _("Big Endian")
109             : info.integer_format == INTEGER_LSB_FIRST ? _("Little Endian")
110             : _("Unknown"));
111   tab_text (t, 0, 4, TAB_LEFT, _("Real Format:"));
112   tab_text (t, 1, 4, TAB_LEFT,
113             info.float_format == FLOAT_IEEE_DOUBLE_LE ? _("IEEE 754 LE.")
114             : info.float_format == FLOAT_IEEE_DOUBLE_BE ? _("IEEE 754 BE.")
115             : info.float_format == FLOAT_VAX_D ? _("VAX D.")
116             : info.float_format == FLOAT_VAX_G ? _("VAX G.")
117             : info.float_format == FLOAT_Z_LONG ? _("IBM 390 Hex Long.")
118             : _("Unknown"));
119   tab_text (t, 0, 5, TAB_LEFT, _("Variables:"));
120   tab_text_format (t, 1, 5, TAB_LEFT, "%zu", dict_get_var_cnt (d));
121   tab_text (t, 0, 6, TAB_LEFT, _("Cases:"));
122   if (info.case_cnt == -1)
123     tab_text (t, 1, 6, TAB_LEFT, _("Unknown"));
124   else
125     tab_text_format (t, 1, 6, TAB_LEFT, "%ld", (long int) info.case_cnt);
126   tab_text (t, 0, 7, TAB_LEFT, _("Type:"));
127   tab_text (t, 1, 7, TAB_LEFT, _("System File"));
128   tab_text (t, 0, 8, TAB_LEFT, _("Weight:"));
129   {
130     struct variable *weight_var = dict_get_weight (d);
131     tab_text (t, 1, 8, TAB_LEFT,
132               (weight_var != NULL
133                ? var_get_name (weight_var) : _("Not weighted.")));
134   }
135   tab_text (t, 0, 9, TAB_LEFT, _("Mode:"));
136   tab_text_format (t, 1, 9, TAB_LEFT,
137                    _("Compression %s."), info.compressed ? _("on") : _("off"));
138
139
140   tab_text (t, 0, 10, TAB_LEFT, _("Charset:"));
141   tab_text (t, 1, 10, TAB_LEFT, dict_get_encoding (d));
142
143
144   tab_submit (t);
145
146   t = tab_create (4, 1 + 2 * dict_get_var_cnt (d));
147   tab_headers (t, 0, 0, 1, 0);
148   tab_text (t, 0, 0, TAB_LEFT | TAT_TITLE, _("Variable"));
149   tab_joint_text (t, 1, 0, 2, 0, TAB_LEFT | TAT_TITLE, _("Description"));
150   tab_text (t, 3, 0, TAB_LEFT | TAT_TITLE, _("Position"));
151   tab_hline (t, TAL_2, 0, 3, 1);
152   for (r = 1, i = 0; i < dict_get_var_cnt (d); i++)
153     r = describe_variable (dict_get_var (d, i), t, r, 3,
154                            DF_ALL & ~DF_AT_ATTRIBUTES);
155
156   tab_box (t, TAL_1, TAL_1, -1, -1, 0, 0, 3, r);
157   tab_vline (t, TAL_1, 1, 0, r);
158   tab_vline (t, TAL_1, 3, 0, r);
159
160   tab_resize (t, -1, r);
161   tab_submit (t);
162
163   dict_destroy (d);
164
165   fh_unref (h);
166   return CMD_SUCCESS;
167 }
168 \f
169 /* DISPLAY utility. */
170
171 static void display_macros (void);
172 static void display_documents (const struct dictionary *dict);
173 static void display_variables (const struct variable **, size_t, int);
174 static void display_vectors (const struct dictionary *dict, int sorted);
175 static void display_data_file_attributes (struct attrset *, int flags);
176
177 int
178 cmd_display (struct lexer *lexer, struct dataset *ds)
179 {
180   /* Whether to sort the list of variables alphabetically. */
181   int sorted;
182
183   /* Variables to display. */
184   size_t n;
185   const struct variable **vl;
186
187   if (lex_match_id (lexer, "MACROS"))
188     display_macros ();
189   else if (lex_match_id (lexer, "DOCUMENTS"))
190     display_documents (dataset_dict (ds));
191   else if (lex_match_id (lexer, "FILE"))
192     {
193       if (!lex_force_match_id (lexer, "LABEL"))
194         return CMD_FAILURE;
195       if (dict_get_label (dataset_dict (ds)) == NULL)
196         tab_output_text (TAB_LEFT,
197                          _("The active dataset does not have a file label."));
198       else
199         tab_output_text_format (TAB_LEFT, _("File label: %s"),
200                                 dict_get_label (dataset_dict (ds)));
201     }
202   else
203     {
204       int flags;
205
206       sorted = lex_match_id (lexer, "SORTED");
207
208       if (lex_match_id (lexer, "VECTORS"))
209         {
210           display_vectors (dataset_dict(ds), sorted);
211           return CMD_SUCCESS;
212         }
213       else if (lex_match_id (lexer, "SCRATCH")) 
214         {
215           dict_get_vars (dataset_dict (ds), &vl, &n, DC_ORDINARY);
216           flags = 0;
217         }
218       else 
219         {
220           struct subcommand 
221             {
222               const char *name;
223               int flags;
224             };
225           static const struct subcommand subcommands[] = 
226             {
227               {"@ATTRIBUTES", DF_ATTRIBUTES | DF_AT_ATTRIBUTES},
228               {"ATTRIBUTES", DF_ATTRIBUTES},
229               {"DICTIONARY", DF_ALL & ~DF_AT_ATTRIBUTES},
230               {"INDEX", DF_DICT_INDEX},
231               {"LABELS", DF_DICT_INDEX | DF_VARIABLE_LABELS},
232               {"NAMES", 0},
233               {"VARIABLES",
234                DF_DICT_INDEX | DF_FORMATS | DF_MISSING_VALUES | DF_MISC},
235               {NULL, 0},
236             };
237           const struct subcommand *sbc;
238
239           flags = 0;
240           for (sbc = subcommands; sbc->name != NULL; sbc++)
241             if (lex_match_id (lexer, sbc->name))
242               {
243                 flags = sbc->flags;
244                 break;
245               }
246
247           lex_match (lexer, T_SLASH);
248           lex_match_id (lexer, "VARIABLES");
249           lex_match (lexer, T_EQUALS);
250
251           if (lex_token (lexer) != T_ENDCMD)
252             {
253               if (!parse_variables_const (lexer, dataset_dict (ds), &vl, &n,
254                                           PV_NONE))
255                 {
256                   free (vl);
257                   return CMD_FAILURE;
258                 }
259             }
260           else
261             dict_get_vars (dataset_dict (ds), &vl, &n, 0);
262         }
263
264       if (n > 0) 
265         {
266           sort (vl, n, sizeof *vl,
267                 (sorted
268                  ? compare_var_ptrs_by_name
269                  : compare_var_ptrs_by_dict_index), NULL);
270           display_variables (vl, n, flags);
271         }
272       else
273         msg (SW, _("No variables to display."));
274       free (vl);
275
276       if (flags & (DF_ATTRIBUTES | DF_AT_ATTRIBUTES))
277         display_data_file_attributes (dict_get_attributes (dataset_dict (ds)),
278                                       flags);
279     }
280
281   return CMD_SUCCESS;
282 }
283
284 static void
285 display_macros (void)
286 {
287   tab_output_text (TAB_LEFT, _("Macros not supported."));
288 }
289
290 static void
291 display_documents (const struct dictionary *dict)
292 {
293   const struct string_array *documents = dict_get_documents (dict);
294
295   if (string_array_is_empty (documents))
296     tab_output_text (TAB_LEFT, _("The active dataset dictionary does not "
297                                  "contain any documents."));
298   else
299     {
300       size_t i;
301
302       tab_output_text (TAB_LEFT | TAT_TITLE,
303                        _("Documents in the active dataset:"));
304       for (i = 0; i < dict_get_document_line_cnt (dict); i++)
305         tab_output_text (TAB_LEFT | TAB_FIX, dict_get_document_line (dict, i));
306     }
307 }
308
309 static void
310 display_variables (const struct variable **vl, size_t n, int flags)
311 {
312   struct tab_table *t;
313   int nc;                       /* Number of columns. */
314   int pc;                       /* `Position column' */
315   int r;                        /* Current row. */
316   size_t i;
317
318   /* One column for the name,
319      two columns for general description,
320      one column for dictionary index. */
321   nc = 1;
322   if (flags & ~DF_DICT_INDEX)
323     nc += 2;
324   pc = nc;
325   if (flags & DF_DICT_INDEX)
326     nc++;
327
328   t = tab_create (nc, n + 5);
329   tab_headers (t, 0, 0, 1, 0);
330   tab_hline (t, TAL_2, 0, nc - 1, 1);
331   tab_text (t, 0, 0, TAB_LEFT | TAT_TITLE, _("Variable"));
332   if (flags & ~DF_DICT_INDEX) 
333     tab_joint_text (t, 1, 0, 2, 0, TAB_LEFT | TAT_TITLE,
334                     (flags & ~(DF_DICT_INDEX | DF_VARIABLE_LABELS)
335                      ? _("Description") : _("Label")));
336   if (flags & DF_DICT_INDEX)
337     tab_text (t, pc, 0, TAB_LEFT | TAT_TITLE, _("Position"));
338
339   r = 1;
340   for (i = 0; i < n; i++)
341     r = describe_variable (vl[i], t, r, pc, flags);
342   tab_hline (t, flags & ~DF_DICT_INDEX ? TAL_2 : TAL_1, 0, nc - 1, 1);
343   if (flags)
344     {
345       tab_box (t, TAL_1, TAL_1, -1, -1, 0, 0, nc - 1, r - 1);
346       tab_vline (t, TAL_1, 1, 0, r - 1);
347     }
348   if (flags & ~DF_DICT_INDEX)
349     tab_vline (t, TAL_1, nc - 1, 0, r - 1);
350   tab_resize (t, -1, r);
351   tab_submit (t);
352 }
353 \f
354 static bool
355 is_at_name (const char *name) 
356 {
357   return name[0] == '@' || (name[0] == '$' && name[1] == '@');
358 }
359
360 static size_t
361 count_attributes (const struct attrset *set, int flags) 
362 {
363   struct attrset_iterator i;
364   struct attribute *attr;
365   size_t n_attrs;
366   
367   n_attrs = 0;
368   for (attr = attrset_first (set, &i); attr != NULL;
369        attr = attrset_next (set, &i)) 
370     if (flags & DF_AT_ATTRIBUTES || !is_at_name (attribute_get_name (attr)))
371       n_attrs += attribute_get_n_values (attr);
372   return n_attrs;
373 }
374
375 static void
376 display_attributes (struct tab_table *t, const struct attrset *set, int flags,
377                     int c, int r)
378 {
379   struct attrset_iterator i;
380   struct attribute *attr;
381
382   for (attr = attrset_first (set, &i); attr != NULL;
383        attr = attrset_next (set, &i)) 
384     {
385       const char *name = attribute_get_name (attr);
386       size_t n_values;
387       size_t i;
388
389       if (!(flags & DF_AT_ATTRIBUTES) && is_at_name (name))
390         continue;
391
392       n_values = attribute_get_n_values (attr);
393       for (i = 0; i < n_values; i++)
394         {
395           if (n_values > 1)
396             tab_text_format (t, c, r, TAB_LEFT, "%s[%zu]", name, i + 1);
397           else
398             tab_text (t, c, r, TAB_LEFT, name);
399           tab_text (t, c + 1, r, TAB_LEFT, attribute_get_value (attr, i));
400           r++;
401         }
402     }
403 }
404
405 static void
406 display_data_file_attributes (struct attrset *set, int flags) 
407 {
408   struct tab_table *t;
409   size_t n_attrs;
410
411   n_attrs = count_attributes (set, flags);
412   if (!n_attrs)
413     return;
414
415   t = tab_create (2, n_attrs + 1);
416   tab_headers (t, 0, 0, 1, 0);
417   tab_box (t, TAL_1, TAL_1, -1, TAL_1, 0, 0, tab_nc (t) - 1, tab_nr (t) - 1);
418   tab_hline (t, TAL_2, 0, 1, 1); 
419   tab_text (t, 0, 0, TAB_LEFT | TAT_TITLE, _("Attribute"));
420   tab_text (t, 1, 0, TAB_LEFT | TAT_TITLE, _("Value"));
421   display_attributes (t, set, flags, 0, 1);
422   tab_title (t, "Custom data file attributes.");
423   tab_submit (t);
424 }
425
426 /* Puts a description of variable V into table T starting at row
427    R.  The variable will be described in the format given by
428    FLAGS.  Returns the next row available for use in the
429    table. */
430 static int
431 describe_variable (const struct variable *v, struct tab_table *t, int r,
432                    int pc, int flags)
433 {
434   size_t n_attrs = 0;
435   int need_rows;
436
437   /* Make sure that enough rows are allocated. */
438   need_rows = 1;
439   if (flags & ~(DF_DICT_INDEX | DF_VARIABLE_LABELS))
440     need_rows += 15;
441   if (flags & DF_VALUE_LABELS)
442     need_rows += val_labs_count (var_get_value_labels (v));
443   if (flags & (DF_ATTRIBUTES | DF_AT_ATTRIBUTES))
444     {
445       n_attrs = count_attributes (var_get_attributes (v), flags);
446       need_rows += n_attrs; 
447     }
448   if (r + need_rows > tab_nr (t))
449     {
450       int nr = MAX (r + need_rows, tab_nr (t) * 2);
451       tab_realloc (t, -1, nr);
452     }
453
454   /* Put the name, var label, and position into the first row. */
455   tab_text (t, 0, r, TAB_LEFT, var_get_name (v));
456   if (flags & DF_DICT_INDEX)
457     tab_text_format (t, pc, r, 0, "%zu", var_get_dict_index (v) + 1);
458
459   if (flags & DF_VARIABLE_LABELS && var_has_label (v))
460     {
461       tab_joint_text (t, 1, r, 2, r, TAB_LEFT, var_get_label (v));
462       r++;
463     }
464
465   /* Print/write format, or print and write formats. */
466   if (flags & DF_FORMATS) 
467     {
468       const struct fmt_spec *print = var_get_print_format (v);
469       const struct fmt_spec *write = var_get_write_format (v);
470
471       if (fmt_equal (print, write))
472         {
473           char str[FMT_STRING_LEN_MAX + 1];
474           tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
475                                  _("Format: %s"), fmt_to_string (print, str));
476           r++;
477         }
478       else
479         {
480           char str[FMT_STRING_LEN_MAX + 1];
481           tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
482                                  _("Print Format: %s"),
483                                  fmt_to_string (print, str));
484           r++;
485           tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
486                                  _("Write Format: %s"),
487                                  fmt_to_string (write, str));
488           r++;
489         }
490     }
491   
492   /* Measurement level, display width, alignment. */
493   if (flags & DF_MISC) 
494     {
495       enum measure m = var_get_measure (v);
496       enum alignment a = var_get_alignment (v);
497
498       tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
499                              _("Measure: %s"),
500                              m == MEASURE_NOMINAL ? _("Nominal")
501                              : m == MEASURE_ORDINAL ? _("Ordinal")
502                              : _("Scale"));
503       r++;
504       tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
505                              _("Display Alignment: %s"),
506                              a == ALIGN_LEFT ? _("Left")
507                              : a == ALIGN_CENTRE ? _("Center")
508                              : _("Right"));
509       r++;
510       tab_joint_text_format (t, 1, r, 2, r, TAB_LEFT,
511                              _("Display Width: %d"),
512                              var_get_display_width (v));
513       r++;
514     }
515   
516   /* Missing values if any. */
517   if (flags & DF_MISSING_VALUES && var_has_missing_values (v))
518     {
519       const struct missing_values *mv = var_get_missing_values (v);
520       char buf[128];
521       char *cp;
522       int cnt = 0;
523       int i;
524
525       cp = stpcpy (buf, _("Missing Values: "));
526
527       if (mv_has_range (mv))
528         {
529           double x, y;
530           mv_get_range (mv, &x, &y);
531           if (x == LOWEST)
532             cp += sprintf (cp, "LOWEST THRU %g", y);
533           else if (y == HIGHEST)
534             cp += sprintf (cp, "%g THRU HIGHEST", x);
535           else
536             cp += sprintf (cp, "%g THRU %g", x, y);
537           cnt++;
538         }
539       for (i = 0; i < mv_n_values (mv); i++)
540         {
541           const union value *value = mv_get_value (mv, i);
542           if (cnt++ > 0)
543             cp += sprintf (cp, "; ");
544           if (var_is_numeric (v))
545             cp += sprintf (cp, "%g", value->f);
546           else
547             {
548               int width = var_get_width (v);
549               int mv_width = MIN (width, MV_MAX_STRING);
550
551               *cp++ = '"';
552               memcpy (cp, value_str (value, width), mv_width);
553               cp += mv_width;
554               *cp++ = '"';
555               *cp = '\0';
556             }
557         }
558
559       tab_joint_text (t, 1, r, 2, r, TAB_LEFT, buf);
560       r++;
561     }
562
563   /* Value labels. */
564   if (flags & DF_VALUE_LABELS && var_has_value_labels (v))
565     {
566       const struct val_labs *val_labs = var_get_value_labels (v);
567       size_t n_labels = val_labs_count (val_labs);
568       const struct val_lab **labels;
569       int orig_r = r;
570       size_t i;
571
572 #if 0
573       tab_text (t, 1, r, TAB_LEFT, _("Value"));
574       tab_text (t, 2, r, TAB_LEFT, _("Label"));
575       r++;
576 #endif
577
578       tab_hline (t, TAL_1, 1, 2, r);
579
580       labels = val_labs_sorted (val_labs);
581       for (i = 0; i < n_labels; i++)
582         {
583           const struct val_lab *vl = labels[i];
584
585           tab_value (t, 1, r, TAB_NONE, &vl->value, v, NULL);
586           tab_text (t, 2, r, TAB_LEFT, val_lab_get_escaped_label (vl));
587           r++;
588         }
589       free (labels);
590
591       tab_vline (t, TAL_1, 2, orig_r, r - 1);
592     }
593
594   if (flags & (DF_ATTRIBUTES | DF_AT_ATTRIBUTES) && n_attrs)
595     {
596       tab_joint_text (t, 1, r, 2, r, TAB_LEFT, "Custom attributes:");
597       r++;
598
599       display_attributes (t, var_get_attributes (v), flags, 1, r);
600       r += n_attrs;
601     }
602
603   /* Draw a line below the last row of information on this variable. */
604   tab_hline (t, TAL_1, 0, tab_nc (t) - 1, r);
605
606   return r;
607 }
608
609 /* Display a list of vectors.  If SORTED is nonzero then they are
610    sorted alphabetically. */
611 static void
612 display_vectors (const struct dictionary *dict, int sorted)
613 {
614   const struct vector **vl;
615   int i;
616   struct tab_table *t;
617   size_t nvec;
618   size_t nrow;
619   size_t row;
620
621   nvec = dict_get_vector_cnt (dict);
622   if (nvec == 0)
623     {
624       msg (SW, _("No vectors defined."));
625       return;
626     }
627
628   vl = xnmalloc (nvec, sizeof *vl);
629   nrow = 0;
630   for (i = 0; i < nvec; i++)
631     {
632       vl[i] = dict_get_vector (dict, i);
633       nrow += vector_get_var_cnt (vl[i]);
634     }
635   if (sorted)
636     qsort (vl, nvec, sizeof *vl, compare_vector_ptrs_by_name);
637
638   t = tab_create (4, nrow + 1);
639   tab_headers (t, 0, 0, 1, 0);
640   tab_box (t, TAL_1, TAL_1, -1, -1, 0, 0, 3, nrow);
641   tab_box (t, -1, -1, -1, TAL_1, 0, 0, 3, nrow);
642   tab_hline (t, TAL_2, 0, 3, 1);
643   tab_text (t, 0, 0, TAT_TITLE | TAB_LEFT, _("Vector"));
644   tab_text (t, 1, 0, TAT_TITLE | TAB_LEFT, _("Position"));
645   tab_text (t, 2, 0, TAT_TITLE | TAB_LEFT, _("Variable"));
646   tab_text (t, 3, 0, TAT_TITLE | TAB_LEFT, _("Print Format"));
647
648   row = 1;
649   for (i = 0; i < nvec; i++)
650     {
651       const struct vector *vec = vl[i];
652       size_t j;
653
654       tab_joint_text (t, 0, row, 0, row + vector_get_var_cnt (vec) - 1,
655                       TAB_LEFT, vector_get_name (vl[i]));
656
657       for (j = 0; j < vector_get_var_cnt (vec); j++)
658         {
659           struct variable *var = vector_get_var (vec, j);
660           char fmt_string[FMT_STRING_LEN_MAX + 1];
661           fmt_to_string (var_get_print_format (var), fmt_string);
662
663           tab_text_format (t, 1, row, TAB_RIGHT, "%zu", j + 1);
664           tab_text (t, 2, row, TAB_LEFT, var_get_name (var));
665           tab_text (t, 3, row, TAB_LEFT, fmt_string);
666           row++;
667         }
668       tab_hline (t, TAL_1, 0, 3, row);
669     }
670
671   tab_submit (t);
672
673   free (vl);
674 }